Legend:
Library
Module
Module type
Parameter
Class
Class type
A dynamic single-use countdown latch.
Latches are typically used for determining when a finite set of parallel computations is done. If the size of the set is known a priori, then the latch can be initialized with the size as initial count and then each computation just decrements the latch.
If the size is unknown, i.e. it is determined dynamically, then a latch is initialized with a count of one, the a priori known computations are started and then the latch is decremented. When a computation is stsrted, the latch is incremented, and then decremented once the computation has finished.
try_decr latch attempts to decrement the count of the latch and returns true in case the count of the latch was greater than zero and false in case the count already was zero.
try_incr latch attempts to increment the count of the latch and returns true on success and false on failure, which means that the latch has already reached zero.