8.17
Condition Variables
(require data/condvar) | package: condvar-lib |
This module provides an implementation of Condition Variables built on top of Racket’s semaphores.
procedure
v : any/c
procedure
(make-condvar) → condvar?
The make-condvar procedure returns a new condition
variable.
procedure
(condvar-signal cvar) → void?
cvar : condvar?
Wakes up one of cvar’s waiters.
procedure
(condvar-broadcast cvar) → void?
cvar : condvar?
Wakes up all of cvar’s waiters.
procedure
(condvar-wait-evt cvar mutex) → (evt/c semaphore?)
cvar : condvar? mutex : semaphore?
Returns a synchronizable event that may become ready for synchronization when the
condition variable is signaled. The synchronization result of the
event is mutex.
The mutex argument must be a semaphore whose internal counter is zero at the time condvar-wait-evt is called. This procedure increments the mutex internally after adding the waiter to the waitlist, then decrements it once the returned event is selected for synchronization.
procedure
(condvar-wait cvar mutex) → semaphore?
cvar : condvar? mutex : semaphore?