...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::timed_read_write_mutex —
The timed_read_write_mutex class is a model of the TimedReadWriteMutex concept.
Note | |
---|---|
Unfortunately it turned out that the current implementation of Read/Write Mutex has some serious problems. So it was decided not to put this implementation into release grade code. Also discussions on the mailing list led to the conclusion that the current concepts need to be rethought. In particular the schedulings Inter-Class Scheduling Policies are deemed unnecessary. There seems to be common belief that a fair scheme suffices. The following documentation has been retained however, to give readers of this document the opportunity to study the original design. |
class timed_read_write_mutex { public: // types typedef implementation-defined scoped_read_write_lock; typedef implementation-defined scoped_try_read_write_lock; typedef implementation-defined scoped_timed_read_write_lock; typedef implementation-defined scoped_read_lock; typedef implementation-defined scoped_try_read_lock; typedef implementation-defined scoped_timed_read_lock; typedef implementation-defined scoped_write_lock; typedef implementation-defined scoped_try_write_lock; typedef implementation-defined scoped_timed_write_lock; // construct/copy/destruct timed_read_write_mutex(boost::read_write_scheduling_policy); ~timed_read_write_mutex(); };
The timed_read_write_mutex class is a model of the TimedReadWriteMutex concept. It should be used to synchronize access to shared resources using Unspecified locking mechanics.
For classes that model related mutex concepts, see read_write_mutex and try_read_write_mutex.
The timed_read_write_mutex class supplies the following typedefs, which model the specified locking strategies:
Lock Name | Lock Concept |
---|---|
scoped_read_write_lock | ScopedReadWriteLock |
scoped_try_read_write_lock | ScopedTryReadWriteLock |
scoped_timed_read_write_lock | ScopedTimedReadWriteLock |
scoped_read_lock | ScopedLock |
scoped_try_read_lock | ScopedTryLock |
scoped_timed_read_lock | ScopedTimedLock |
scoped_write_lock | ScopedLock |
scoped_try_write_lock | ScopedTryLock |
scoped_timed_write_lock | ScopedTimedLock |
The timed_read_write_mutex class uses an
Unspecified
locking strategy, so attempts to recursively lock a timed_read_write_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 read/write mutex models in Boost.Thread, timed_read_write_mutex has two types of scheduling policies, an inter-class sheduling policy between threads trying to obtain different types of locks and an intra-class sheduling policy between threads trying to obtain the same type of lock. The timed_read_write_mutex class allows the programmer to choose what inter-class sheduling policy will be used; however, like all read/write mutex models, timed_read_write_mutex leaves the intra-class sheduling policy as Unspecified.
Note | |
---|---|
Self-deadlock is virtually guaranteed if a thread tries to lock the same timed_read_write_mutex multiple times unless all locks are read-locks (but see below) |
timed_read_write_mutex
construct/copy/destructtimed_read_write_mutex(boost::read_write_scheduling_policy count);
Effects: | Constructs a timed_read_write_mutex object. |
Postconditions: |
*this is in an unlocked state.
|
~timed_read_write_mutex();
Effects: | Destroys a timed_read_write_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 |