Next: , Previous: Mutex Support, Up: Threading


12.5 Semaphores

described here should be considered experimental, subject to API changes without notice.

— Structure: semaphore [sb-thread]

Class precedence list: semaphore, structure-object, t

Semaphore type. The fact that a semaphore is a structure-object should be considered an implementation detail, and may change in the future.

— Function: make-semaphore [sb-thread] &key name count

Create a semaphore with the supplied count and name.

— Function: semaphore-count [sb-thread] instance

Returns the current count of the semaphore instance.

— Function: semaphore-name [sb-thread] instance

Name of a mailbox. SETFable.

— Function: signal-semaphore [sb-thread] semaphore &optional n

Increment the count of semaphore by n. If there are threads waiting on this semaphore, then n of them is woken up.

— Function: try-semaphore [sb-thread] semaphore &optional n

Try to decrement the count of semaphore by n. If the count were to become negative, punt and return nil, otherwise return true.

— Function: wait-on-semaphore [sb-thread] semaphore

Decrement the count of semaphore if the count would not be negative. Else blocks until the semaphore can be decremented.