lock mtx
locks mtx
, possibly waiting for it to be released
first by another thread.
Unix_error
if 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
.
unlock mtx
unlocks mtx
.
Unix_error
if 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.