repo.or.cz
/
supercollider.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
history
|
raw
|
HEAD
cmake build system: visiblity support for clang
[supercollider.git]
/
SCClassLibrary
/
Common
/
Core
/
Semaphore.sc
blob
5863fb1a31e6401abff8b3e1ff38e8794f96a517
1
Semaphore {
2
var <count, waitingThreads;
3
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
}
25
}