cmake build system: visiblity support for clang
[supercollider.git] / SCClassLibrary / Common / Core / Semaphore.sc
blob5863fb1a31e6401abff8b3e1ff38e8794f96a517
1 Semaphore {
2         var <count, waitingThreads;
4         *new { | count=1 |
5                 ^super.newCopyArgs(count, LinkedList.new)
6         }
7         clear {
8                 waitingThreads = LinkedList.new;
9         }
10         wait {
11                 count = count - 1;
12                 if (count < 0) {
13                         waitingThreads.add(thisThread);
14                         nil.yield;
15                 };
16         }
17         signal {
18                 var thread;
19                 count = count + 1;
20                 thread = waitingThreads.popFirst;
21                 if (thread.notNil) {
22                         thread.clock.sched(0, thread);
23                 };
24         }