package picos_std
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=862d61383e2df93a876bedcffb1fd1ddc0f96c50b0e9c07943a2aee1f0e182be
sha512=87805379017ef4a7f2c11b954625a3757a0f1431bb9ba59132202de278b3e41adbe0cdc20e3ab23b7c9a8c5a15faeb7ec79348e7d80f2b14274b00df0893b8c0
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"
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.