Version 0.8.8

Common Lisp threading library



wait-on-semaphore semaphore &key timeout -> generalized-boolean

Arguments and values:

semaphore -> a semaphore object.
timeout -> a non-negative real number.
generalized-boolean -> a generalized boolean.


Decrement the count of semaphore by 1 if the count is larger than zero.
If the count is zero, blocks until semaphore can be decremented. Returns true on success.

If timeout is given, it is the maximum number of seconds to wait. If the count cannot be decremented in that time, returns false without decrementing the count.

Exceptional situations:

Signals an error of type type-error if semaphore is not a semaphore object.
Signals an error of type type-error if timeout is neither nil nor a non-negative real number.

See also:

make-semaphore, wait-on-semaphore


It is unspecified which thread gets a wakeup and does not necessarily relate to the order in which the threads went to sleep.

On Allegro, a non-null timeout is forced to a minimum of 100ms, because Allegro does not provide a primitive for waiting with a timeout, which is emulated using with-timeout.

Last updated on 2022-01-07
Published on 2022-01-07
Edit on GitHub