Waits on a barrier until enough threads arrive.
A function designator.
barrier-wait waits on a barrier until enough threads arrive on barrier. When
barrier-wait is called, it "arrives", and when the number of arrivers reaches the count of the barrier (that is, the count argument to make-barrier),
barrier-wait returns. Effectively, the last "arriver" unblocks the barrier and wakes up all the other waiting threads.
barrier-wait first checks whether barrier is disabled, and if it is then
nil immediately. It then checks the number of arrivers of barrier, which is the number of other calls to
barrier-wait on the same barrier since it was last unblocked or created.
If the number of arrivers is less than the count minus 1,
barrier-wait increases the number of arrivers by 1, and then waits for barrier to be unblocked (unless pass-through is true, which causes it to return immediately). If the number of arrivers of barrier equals its count minus 1, then
barrier-wait unblocks barrier (as described below) and returns
discount-on-abort, discount-on-timeout, disable-on-unblock and callback allow you to control how
barrier-wait waits and also how barrier is unblocking. For each of these, the effective value is either that supplied to
barrier-wait, or if it was not supplied to
barrier-wait, the value in barrier itself (see make-barrier).
timeout can be used to limit the time that
barrier-wait waits. It is either a number of seconds or
nil (the default), meaning wait forever. If
barrier-wait times out, it returns
:timeout. By default it does not change the number of arrivers after a timeout, so the call is still counted as an "arrival", but this can be changed by using discount-on-timeout. If discount-on-timeout is true then
barrier-wait decrements the arrivers count after a timeout, so the call has no overall effect on the arrivers count.
barrier-wait is aborted while it waits (for example by process-terminate or throwing using process-interrupt), it does not change the arrivers count by default, so the call still counts as an arrival, but this can be changed by using discount-on-abort. If discount-on-abort is true, then
barrier-wait decrements the arrivers count on aborting, so the call has no overall effect on the arrivers count.
barrier-wait would have waited but pass-through is true, it returns the symbol
:passed-through instead of waiting. Hence a call to
barrier-wait with a true value of pass-through has the effect of incrementing the arriver count, and unblocking other waiters if needed, but never itself waiting.
barrier-waitwill wait, as if barrier had just been created.
barrier-waitthen disables barrier. Until it is re-enabled, any other call to
barrier-waitwill return immediately.
The current process waited and some other process unblocked barrier.
The current process unblocked barrier.
The wait timed out.
barrier is disabled.
LispWorks User Guide and Reference Manual - 20 Sep 2017