12#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
13 #include <dispatch/dispatch.h>
21 void signal(
int n) {
while (n --> 0) { dispatch_semaphore_signal(
fSemaphore); } }
22 void wait() { dispatch_semaphore_wait(
fSemaphore, DISPATCH_TIME_FOREVER); }
24#elif defined(SK_BUILD_FOR_WIN)
56 while(sem_wait(&
fSemaphore) == -1 && errno == EINTR);
67void SkSemaphore::osSignal(
int n) {
68 fOSSemaphoreOnce([
this] { fOSSemaphore =
new OSSemaphore; });
72void SkSemaphore::osWait() {
73 fOSSemaphoreOnce([
this] { fOSSemaphore =
new OSSemaphore; });
78 int count = fCount.load(std::memory_order_relaxed);
80 return fCount.compare_exchange_weak(
count,
count-1, std::memory_order_acquire);