All Manuals > LispWorks® User Guide and Reference Manual > 42 The MP Package

make-barrier Function

Summary

Returns a new barrier.

Package

mp

Signature

make-barrier count &key discount-on-abort discount-on-timeout callback disable-on-unblock name => barrier

Arguments
count
A positive fixnum or t.
discount-on-abort
A boolean.
discount-on-timeout
A boolean.
callback
A function designator for a function of one argument.
disable-on-unblock
A boolean.
name
A string.
Values
barrier
Description

The function make-barrier returns a new barrier with count count.

count can be t, which is interpreted as most-positive-fixnum.

barrier has the name name, which is useful for debugging but is not used otherwise. If name is omitted, then a default name is generated that is unique among all such default names.

discount-on-timeout and discount-on-abort determine the default behavior when a thread times out or aborts while in the function barrier-wait. See the documentation for barrier-wait.

If disable-on-unblock is true, then barrier-wait will disable barrier by default when it unblocks it. See disable-on-unblock in the documentation for barrier-wait.

callback is called by barrier-wait just before it unblocks barrier. It is called with a single argument, barrier, while holding an internal lock in barrier that will prevent other operations on barrier from running. The callback is guaranteed to happen before barrier-wait allows any of the other threads to continue.

Notes

Because the callback is called inside a lock, you should ensure that it is relatively short to prevent congestion if another thread tries to access barrier. Allocating a few objects is reasonable. If there is a more expensive operation that has to be done by only one of the threads, it can be done by the thread that returned :unblocked from barrier-wait. The advantage of using the callback is that it is called before any of the waiting threads pass the barrier.

See also

barrier
barrier-arriver-count
barrier-block-and-wait
barrier-change-count
barrier-count
barrier-disable
barrier-enable
barrier-name
barrier-pass-through
barrier-unblock
barrier-wait
19.7.2 Synchronization barriers


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:51