Home | Libraries | People | FAQ | More |
class mutex : private boost::noncopyable // Exposition only { public: // types typedef implementation-defined scoped_lock; // construct/copy/destruct mutex(); ~mutex(); };
The mutex class is a model of the Mutex concept. It should be used to synchronize access to shared resources using Unspecified locking mechanics.
For classes that model related mutex concepts, see try_mutex and timed_mutex.
For Recursive locking mechanics, see recursive_mutex, recursive_try_mutex, and recursive_timed_mutex.
The mutex class supplies the following typedef, which models the specified locking strategy:
Lock Name | Lock Concept |
---|---|
scoped_lock | ScopedLock |
The mutex class uses an
Unspecified
locking strategy, so attempts to recursively lock a mutex
object or attempts to unlock one by threads that don't own a lock on it result in
undefined behavior.
This strategy allows implementations to be as efficient as possible
on any given platform. It is, however, recommended that
implementations include debugging support to detect misuse when
NDEBUG
is not defined.
Like all mutex models in Boost.Threads, mutex leaves the scheduling policy as Unspecified. Programmers should make no assumptions about the order in which waiting threads acquire a lock.
mutex
construct/copy/destructmutex();
Effects:
Constructs a mutex object.
Postconditions:
*this
is in an unlocked state.
~mutex();
Effects:
Destroys a mutex object.
Requires:
*this
is in an unlocked state.
Notes:
Danger: Destruction of a
locked mutex is a serious programming error resulting in undefined
behavior such as a program crash.
Copyright © 2001-2003 William E. Kempf |