A barrier object.
A positive integer.
A generalized boolean.
nil or a positive real.
barrier is a barrier object made by make-barrier.
barrier-block-and-wait is "using" the barrier, and only one process can do it the same time.
barrier-block-and-wait first tries to mark the barrier as used by the current process. It will fail if another process is inside
barrier-block-and-wait with the same barrier. In this case it does one of three options:
barrier-block-and-wait has successfully marked barrier as used, it changes its count to
t as if by calling
t), which will cause other barrier-wait calls to wait. If unblock is non-nil, it first unblocks all processes that wait on the barrier, so the effect is the same as
The call was successful, and result is the number of arrivers.
barrier is in use, and result is the process that uses it.
barrier-block-and-waitreturns the barrier is still set with
t, that is calls to barrier-wait on barrier will wait. Normally the current process will go on to do some operations that require the other processes to wait, and then release them by calling barrier-disable or barrier-enable.
barrier-block-and-waitwith wait-if-used-p non-nil),
barrier-block-and-waitwill return after count processes called barrier-wait and are waiting. That is the intention of
barrier-block-and-wait. If other processes call functions that manipulate the arriver count or the count (barrier-disable, barrier-enable, barrier-unblock, barrier-change-count), then
barrier-block-and-waitwill "get confused", in the sense that while its behavior is still well-defined, it is not intuitive.
barrier-block-and-waitis useful for controlling a fixed set of processes by another "master" process. The processes in the set need to call barrier-wait at appropriate points. When the "master" process wants to stop them for a while, it calls
barrier-block-and-wait. When it wants to restart them, it calls barrier-disable.
barrier-block-and-waitwith wait-if-used-p non-nil (and count the number of processes in the group minus one). If two of the processes happen to call it at the same time, one will get the barrier, and the other process will have to wait.
barrier-block-and-waitcan be approximated by using barrier-change-count followed by normal process-wait that checks the arrivers count in the wait function.
barrier-block-and-waithas two advantages:
barrier-block-and-wait will wake up immediately when the arriver count reaches the right number. process-wait will wake up only when the scheduler checks the wait function and wakes it up.
LispWorks User Guide and Reference Manual - 13 Feb 2015