Await_sync.SemaphoreA poisonable counting semaphore.
module Acquired_or_would_block : sig ... endA poisonable counting semaphore.
val sexp_of_t : t -> Sexplib0.Sexp.tval sexp_of_t__stack : t @ local -> Sexplib0.Sexp.t @ localval create : ?padded:bool @ local -> (int -> t) @ local @@ portablecreate n creates a new counting semaphore with the given count n.
The optional padded argument specifies whether to pad the data structure to avoid false sharing. See Atomic.make for a longer explanation.
val release : t @ local -> unit @@ portablerelease t increments the count of the semaphore or does nothing in case the semaphore has been poisoned.
val acquire :
Await_kernel.Await.t @ local ->
(t @ local ->
unit) @ local @@ portableacquire w t waits until the count of the semaphore is greater than 0 and then atomically decrements the count.
val acquire_or_cancel :
Await_kernel.Await.t @ local ->
(Await_kernel.Cancellation.t @ local ->
(t @ local ->
unit Await_kernel.Or_canceled.t) @ local) @ local @@ portableacquire_or_cancel w c t is Completed (acquire w t) if c is not canceled, otherwise it is Canceled.
val try_acquire : t @ local -> Acquired_or_would_block.t @@ portabletry_acquire t attempts to atomically and in a wait-free way decrement the count of the semaphore, unless the count is already 0. Returns Acquired if the semaphore was successfully acquired, or Would_block if the count is already 0 and the operation would block
val get_value : t @ local -> int @@ portableget_value t 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 @ local -> unit @@ portablepoison t marks the semaphore as poisoned.