module Netmcore_mutex: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 mutex 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.
Mutexes are special values, and cannot be copied or moved.
Mutexes are implemented on top of semaphores. For mutex types with deadlock handling, the process is considered as the owner, and process ID is the identifier.
Only mutexes of type `Normal are thread-safe, i.e. can be used
when the worker processes also use threads internally.
typemutex_type =[ `Errorcheck | `Normal | `Recursive ]
`Normal mutexes have no checks for deadlocks.`Errorcheck mutexes check whether the process locks the mutex
again, and fail in this case. Also, only the owning process can
unlock a mutex.`Recursive mutexes allow that the owner locks several times.
The same number of unlock requests need to be issued to give
up the ownershiptype mutex
val dummy : unit -> mutexmutex-typed variablesval create : Netmcore_heap.mutator -> mutex_type -> mutexcreate m t: Creates a mutex of type t, and
pushes it to the heap, using the mutator m.
After being pushed to the heap, the mutex can be used. It is
nonsense to copy it outside the heap.
val lock : mutex -> unitval unlock : mutex -> unitval destroy : mutex -> unit