Mutual exclusion primitive (a lock).
If you want to guard shared state, use Mutex α
instead.
Instances For
Creates a new BaseMutex
.
Locks a BaseMutex
. Waits until no other thread has locked the mutex.
The current thread must not have already locked the mutex. Reentrant locking is undefined behavior (inherited from the C++ implementation).
Unlocks a BaseMutex
.
The current thread must have already locked the mutex. Unlocking an unlocked mutex is undefined behavior (inherited from the C++ implementation).
Creates a new condition variable.
Wakes up a single other thread executing wait
.
Wakes up all other threads executing wait
.
Waits on the condition variable until the predicate is true.
Instances For
- ref : IO.Ref α
- mutex : IO.BaseMutex
Mutual exclusion primitive (lock) guarding shared state of type α
.
The type Mutex α
is similar to IO.Ref α
,
except that concurrent accesses are guarded by a mutex
instead of atomic pointer operations and busy-waiting.
Instances For
mutex.atomically k
runs k
with access to the mutex's state while locking the mutex.
Instances For
mutex.atomicallyOnce condvar pred k
runs k
,
waiting on condvar
until pred
returns true.
Both k
and pred
have access to the mutex's state.