The function
semaphore-acquire
acquires
count
units from the semaphore
sem
.
It attempts to atomically decrement the semaphore's unit count by count (which defaults to 1) and returns true if this would give a non negative unit count.
If decrementing the semaphore's unit count would result in a negative number, then
semaphore-acquire
waits until the semaphore's unit count is larger than
count
and tries again. If
wait-reason
is true, then it is used as the thread's
wait-reason
when waiting for the semaphore.
If
timeout
is
nil
,
semaphore-acquire
can wait forever. If
timeout
is true, it should be an integer. If the semaphore count cannot be decremented within
timeout
seconds, then
semaphore-acquire
returns false and the semaphore is unaffected. Pass
timeout
0 if you do not want to wait at all.