Class Signal¶
Defined in File signal.h
Class Documentation¶
-
class Signal¶
A thread-synchronisation barrier.
The expected usage is that one thread sits in
wait()
until signalled from another thread withraise()
.This mechanism does not attempt to ensure that only one thread is released per
raise()
or that eachraise()
unblocks only onewait()
. The only guarantees are that: 1) At least one call toraise()
strongly-happens-before a call towait()
returns, and 2)wait()
will block until a call toraise()
that happens-after the most recent return fromwait()
.The primary use-case for such a barrier is to signal a worker thread to run the next iteration of work.
This is very similar to a
std::binary_semaphore
but without the precondition thatraise()
is not called if the Signal is already raised.Public Functions
-
Signal()¶
-
void raise()¶
Raise the signal, releasing any thread in
wait()
This does not synchronise with any other call to
raise()
This synchronises-with a subsequent call towait()
, but does not guarantee that each call toraise()
releases at least onewait()
.Two unsynchronised calls to
raise()
may result in either one or two calls towait()
being unblocked, depending on timing.
-
Signal()¶