boost.png (6897 bytes) Home Libraries People FAQ More

PrevUpHomeNext

Class timed_mutex

boost::timed_mutex —

The timed_mutex class is a model of the TimedMutex concept.

Synopsis

class timed_mutex : private boost::noncopyable   // Exposition only
{
public:
  // types
  typedef implementation-defined scoped_lock;      
  typedef implementation-defined scoped_try_lock;  
  typedef implementation-defined scoped_timed_lock;

  // construct/copy/destruct
  timed_mutex();
  ~timed_mutex();
};

Description

The timed_mutex class is a model of the TimedMutex concept. It should be used to synchronize access to shared resources using Unspecified locking mechanics.

For classes that model related mutex concepts, see mutex and try_mutex.

For Recursive locking mechanics, see recursive_mutex, recursive_try_mutex, and recursive_timed_mutex.

The timed_mutex class supplies the following typedefs, which model the specified locking strategies:

Lock Name Lock Concept
scoped_lock ScopedLock
scoped_try_lock ScopedTryLock
scoped_timed_lock ScopedTimedLock

The timed_mutex class uses an Unspecified locking strategy, so attempts to recursively lock a timed_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, timed_mutex leaves the scheduling policy as Unspecified. Programmers should make no assumptions about the order in which waiting threads acquire a lock.

timed_mutex construct/copy/destruct

  1. timed_mutex();

    Effects: Constructs a timed_mutex object.
    Postconditions: *this is in an unlocked state.

  2. ~timed_mutex();

    Effects: Destroys a timed_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

PrevUpHomeNext