Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: src/core/SkSemaphore.cpp

Issue 1192433006: SkSemaphore: use SYNC_POLICY_LIFO on Mach. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkSemaphore.h" 8 #include "SkSemaphore.h"
9 9
10 #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) 10 #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
11 #include <mach/mach.h> 11 #include <mach/mach.h>
12 struct SkSemaphore::OSSemaphore { 12 struct SkSemaphore::OSSemaphore {
13 semaphore_t fSemaphore; 13 semaphore_t fSemaphore;
14 14
15 OSSemaphore() { 15 OSSemaphore() {
16 semaphore_create(mach_task_self(), &fSemaphore, SYNC_POLICY_FIFO, 0/ *initial count*/); 16 semaphore_create(mach_task_self(), &fSemaphore, SYNC_POLICY_LIFO, 0/ *initial count*/);
17 } 17 }
18 ~OSSemaphore() { semaphore_destroy(mach_task_self(), fSemaphore); } 18 ~OSSemaphore() { semaphore_destroy(mach_task_self(), fSemaphore); }
19 19
20 void signal(int n) { while (n --> 0) { semaphore_signal(fSemaphore); } } 20 void signal(int n) { while (n --> 0) { semaphore_signal(fSemaphore); } }
21 void wait() { semaphore_wait(fSemaphore); } 21 void wait() { semaphore_wait(fSemaphore); }
22 }; 22 };
23 #elif defined(SK_BUILD_FOR_WIN32) 23 #elif defined(SK_BUILD_FOR_WIN32)
24 struct SkSemaphore::OSSemaphore { 24 struct SkSemaphore::OSSemaphore {
25 HANDLE fSemaphore; 25 HANDLE fSemaphore;
26 26
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 } 78 }
79 79
80 void SkSemaphore::wait() { 80 void SkSemaphore::wait() {
81 // We only wait() on the OS semaphore if the count drops <= 0, 81 // We only wait() on the OS semaphore if the count drops <= 0,
82 // i.e. when we need to make this thread sleep to wait for it to go back up. 82 // i.e. when we need to make this thread sleep to wait for it to go back up.
83 if (fCount.fetch_add(-1, sk_memory_order_acquire) <= 0) { 83 if (fCount.fetch_add(-1, sk_memory_order_acquire) <= 0) {
84 fOSSemaphore->wait(); 84 fOSSemaphore->wait();
85 } 85 }
86 } 86 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698