condvarsstructure) allow threads perform condition synchronization: It allows threads to block, waiting for a specified condition--associated with a condition variable--to occur, and other threads to wake up the waiting threads when the condition is fulfilled.
Note that, in Scheme 48, condition variables work in conjunction with proposals, not with mutex locks or semaphores, as in most other implementations of this concept.
(make-condvar) -> condvar
(make-condvar id) -> condvar
(condvar? thing) -> boolean
(set-condvar-has-value?! condvar boolean)
(condvar-has-value? condvar) -> boolean
(set-condvar-value! condvar value)
(condvar-value condvar) -> value
(maybe-commit-and-wait-for-condvar condvar) -> boolean
(maybe-commit-and-set-condvar! condvar value) -> boolean
Make-condvarcreates a condition variable. (The optional
idargument is only for debugging purposes; the discloser for condition variables prints it out if present.)
Condvar?is the predicate for condition variables.
Each condition variable has an associated value and a flag
has-value? signalling if the condition has already occured.
The accessor for flag is
set-condvar-has-value?! sets it. Both are provisional
operations and go through the current proposal.
Set-condvar-value! sets the value of the condition variable
condvar-value extracts it.
Maybe-commit-and-wait-for-condvar attempts to commit the
current proposal. If the commit succeeds, it suspends the current
thread and registers it with the
condvar condition variable.
Upon waking up again
#t, If the commit fails,
Maybe-commit-and-set-condvar! sets the value of the
condvar condition variable to
has-value? flag to
#t, and then attempt to
commit the current proposal. Upon success, it wakes up all suspended
threads registered with
condvar and returns
otherwise, it returns
Previous: Condition variables | Next: Condition variables