A mutex is a type whose objects can be in either of two states, called
locked and unlocked, with the property that when a thread A has locked a
mutex m and a different thread B tries to lock m,
B is blocked until A unlocks m. Additionally, a mutex is said to
support recursive locking if a thread can succesfully invoke the locking
operation for a mutex already locked by this same thread; in this case, it is
required that the thread execute as many unlock operations as lock
operations it has performed for the mutex to become effectively unlocked.
A scoped lock is a
type associated to some mutex type whose objects do the locking/unlocking
of a mutex on construction/destruction time.

In the following table, Mutex is a mutex type, m
is an object of type Mutex, Lock is a scoped lock
associated to Mutex and lk is a value of
Lock.

Mutex and Scoped Lock requirements.

expression

return type

assertion/notepre/post-condition

Mutex m;

Post: m is unlocked.

(&m)->~Mutex();

void

Pre: m is unlocked.

Lock lk(m);

Associates m to lk and locks m.

(&lk)->~Lock();

void

Unlocks the mutex associated to lk.

These concepts are very similar, but not entirely equivalent, to
the homonym ones described in the
Boost Thread
Library.

Locking Policy that specifies a basic
mutex type based on the simplest synchronization mechanisms provided by
the environment; When no threading capabilities are available,
simple_locking specifies a dummy type without actual
synchronization capabilities.

Null Locking Policy: it specifies a dummy
type that satisfies the formal requirements for the
Mutex concept but does not perform
thread blocking. no_locking should only be used in single-threaded
environments.