Module Fut.Sem
Semaphores for limiting resource usage.
TODO doc.
Semaphores
type 'a future= 'a ttype tokenThe type for tokens.
val create : capacity:int -> tcreate capacityis a semaphore with a token capacity ofcapacity.
val capacity : t -> intcapacity siss's token capacity.
val available : t -> intavailable siss's number of available tokens.
val take : t -> token futuretake sis a future that determines as follows:- If at call time
available s > 0, decrementsavailable sand determines a token immediately. - Otherwise determines when
available sbecomes> 0and all previous futures resulting fromtake shave been set (i.e. you are served in FIFO order).
- If at call time