lock mtx
locks mtx
, possibly waiting for it to be released
first by another thread.
lock
attempts to acquire mtx
recursively.
try_lock
is like lock
, but always returns immediately. If the calling thread or
another one already has the mutex it returns `Already_held_by_me_or_other
, otherwise
it locks it and returns `Acquired
.
timedlock mtx timeout
like lock
, but takes a timeout
parameter.
true
if the mutex was acquired, or false
when timeout
expires otherwise.
timedlock
attempts to acquire mtx
recursively.
unlock mtx
unlocks mtx
.
unlock
attempts to release an unacquired
mutex or a mutex held by another thread.
synchronize f
creates a mutex and returns a new function that is identical to f
except that the mutex is held during its execution.
update_signal mtx cnd ~f
updates some state within a critical
section protected by mutex mtx
using function f
and signals
condition variable cnd
after finishing. If f
raises an exception,
the condition will NOT be signaled!
update_broadcast mtx cnd ~f
updates some state within a critical
section protected by mutex mtx
using function f
and broadcasts
condition variable cnd
after finishing. If f
raises an exception,
the condition will NOT be broadcast!