Picos_std_sync.Sem
A poisonable counting semaphore.
đī¸ This uses a low overhead, optimistic, and unfair implementation. In most cases this should be the semaphore you will want to use.
See also Semaphore
.
Maximum counter value allowed by the semaphore implementation.
âšī¸ The exact maximum value is unspecified, but should typically be no less than Sys.max_array_length
.
val create : ?padded:bool -> int -> t
create initial
creates a new counting semaphore with the given initial
count.
val release : t -> unit
release sem
increments the count of the semaphore or does nothing in case the semaphore has been poisoned.
âšī¸ This operation is not cancelable.
Exception raised in case the semaphore has been poisoned.
val acquire : t -> unit
acquire sem
waits until the count of the semaphore is greater than 0
and then atomically decrements the count.
val try_acquire : t -> bool
try_acquire sem
attempts to atomically decrement the count of the semaphore unless the count is already 0
.
val get_value : t -> int
get_value sem
returns the current count of the semaphore or 0
in case the semaphore has been poisoned.
âšī¸ This should only be used for debugging or informational messages.
val poison : t -> unit
poison sem
marks the semaphore as poisoned.