Module Fut.Sem

module Sem: sig .. end
Semaphores for limiting resource usage.

TODO doc.


type 'a future = 'a Fut.t 
type token 
The type for tokens.
type t 
The type for semaphores.
val create : capacity:int -> t
create capacity is a semaphore with a token capacity of capacity.
val capacity : t -> int
capacity s is s's token capacity.
val available : t -> int
available s is s's number of available tokens.
val take : t -> token future
take s is a future that determines as follows:
val return : t -> token -> unit
return s token returns the token token to s. As a side effect, determines the first non set take s future waiting (if any).
Raises Invalid_argument if token was already returned or if token doesn't belong to s.