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.
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.
&L
without any implication of dereferenceable
for Latch::set
A Latch starts as false and eventually becomes true. You can block
until it becomes true.
Once latches are used to implement one-time blocking, primarily
for the termination flag of the threads in the pool.
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.