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.
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.
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().