Eio.SemaphoreA counting semaphore.
The API is based on OCaml's Semaphore.Counting.
The difference is that when waiting for the semaphore this will switch to the next runnable fiber, whereas the stdlib one will block the whole domain.
Semaphores are thread-safe and so can be shared between domains and used to synchronise between them.
val make : int -> tmake n returns a new counting semaphore, with initial value n. The initial value n must be nonnegative.
val release : t -> unitrelease t increments the value of semaphore t. If other fibers are waiting on t, the one that has been waiting the longest is resumed.
val acquire : t -> unitacquire t blocks the calling fiber until the value of semaphore t is not zero, then atomically decrements the value of t and returns.
val get_value : t -> intget_value t returns the current value of semaphore t.