Module latch

Source

Structsยง

CoreLatch ๐Ÿ”’
Spin latches are the simplest, most efficient kind, but they do not support a wait() operation. They just have a boolean flag that becomes true when set() is called.
CountLatch ๐Ÿ”’
Counting latches are used to implement scopes. They track a counter. Unlike other latches, calling set() does not necessarily make the latch be considered set(); instead, it just decrements the counter. The latch is only โ€œsetโ€ (in the sense that probe() returns true) once the counter reaches zero.
LatchRef ๐Ÿ”’
&L without any implication of dereferenceable for Latch::set
LockLatch ๐Ÿ”’
A Latch starts as false and eventually becomes true. You can block until it becomes true.
OnceLatch ๐Ÿ”’
Once latches are used to implement one-time blocking, primarily for the termination flag of the threads in the pool.
SpinLatch ๐Ÿ”’
Spin latches are the simplest, most efficient kind, but they do not support a wait() operation. They just have a boolean flag that becomes true when set() is called.

Enumsยง

CountLatchKind ๐Ÿ”’

Constantsยง

SET ๐Ÿ”’
Latch is set.
SLEEPING ๐Ÿ”’
Latch is not set, owning thread is asleep on this latch and must be awoken.
SLEEPY ๐Ÿ”’
Latch is not set, owning thread is going to sleep on this latch (but has not yet fallen asleep).
UNSET ๐Ÿ”’
Latch is not set, owning thread is awake

Traitsยง

AsCoreLatch ๐Ÿ”’
Latch ๐Ÿ”’
We define various kinds of latches, which are all a primitive signaling mechanism. A latch starts as false. Eventually someone calls set() and it becomes true. You can test if it has been set by calling probe().