Availability:built-in
with_mutex(+MutexId,
:Goal)Execute Goal while holding MutexId. If Goal
leaves choice points, these are destroyed (as in once/1).
The mutex is unlocked regardless of whether Goal succeeds,
fails or raises an exception. An exception thrown by Goal is
re-thrown after the mutex has been successfully unlocked. See also mutex_create/1
and setup_call_cleanup/3.
Although described in the thread section, this predicate is also
available in the single-threaded version, where it behaves simply as
once/1.