module Netmcore_sem:sig..end
Netmcore_heap), for example in the header field of
Netmcore_array or somewhere else in heap-allocated
data structures.
In order to ensure that the semaphore is in the heap, the
special function create must be used to initialize it
there. As create requires a mutator as argument, this is
only possible by calling create from the callback of
Netmcore_heap.modify.
Semaphores are special values, and cannot be copied or moved.
Note that Netsys_posix provides wrappers for direct use
of the semaphore functionality of the OS. These wrappers, however,
cannot be used together with heaps, because semaphores are
there represented as bigarrays, which cannot be pushed to heaps.
This module here uses a trick to make it possible nevertheless.
type semaphore
val dummy : unit -> semaphoresemaphore-typed variablesval create : Netmcore_heap.mutator -> int -> semaphorecreate m value: Creates a semaphore with initial value, and
pushes it to the heap, using the mutator m.
After being pushed to the heap, the semaphore can be used. It is
nonsense to copy it outside the heap.
val destroy : semaphore -> unitval getvalue : semaphore -> intval post : semaphore -> unitval wait : semaphore -> Netsys_posix.sem_wait_behavior -> unitNetsys_posix.SEM_WAIT_BLOCK: Wait until the semaphore is
postedNetsys_posix.SEM_WAIT_NONBLOCK: Raise EAGAIN