package picos_std
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=3f5a08199cf65c2dae2f7d68f3877178f1da8eabf5376e15114e5a8958087dfa
sha512=ad24910c47ce614268c4268874bb918da7f8b5f03b3ad706bbf30323635262e94ddab6be24eaebbca706bfa82c0a517d4272b396459e020c185942125c9bdb7b
doc/picos_std.sync/Picos_std_sync/Latch/index.html
Module Picos_std_sync.Latch
Source
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.
Represents a dynamic countdown latch.
create initial
creates a new countdown latch with the specified initial
count.
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.
decr latch
is equivalent to:
if not (try_decr latch) then
invalid_arg "zero count"
ℹ️ This operation is not cancelable.
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.
incr latch
is equivalent to:
if not (try_incr latch) then
invalid_arg "zero count"
await_evt latch
returns an event that can be committed to once the count of the latch has reached zero.