Semaphores
val init : 'a option ‑> 'a tinit v initializes a semaphore with an optional value v. If it is
Some x, then Semaphore.wait will return immediately with x,
otherwise it will block until Semaphore.signal is called.
val signal : 'a t ‑> 'a ‑> unitsignal sem v allows one thread blocked in Semaphore.wait on
semaphore sem to continue. The semaphore will then block again
further threads.
val wait : 'a t ‑> 'await sem blocks the calling thread on semaphore sem if it was not
initialized with Some x or not signalled before. The semaphore
is reset to None, i.e. calling wait again will block unless the
semaphore was signalled inbetween.
val get : 'a t ‑> 'a optionget sem returns None if semaphore is not set, Some value
otherwise. The semaphore is reset to None, and a subsequent wait
will block again.
val look : 'a t ‑> 'a optionlook sem
None if semaphore is not set, Some value
otherwise. The state of the semaphore remains unchanged.