Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Lock Concepts

StrictLock -- EXTENSION
L::mutex_type
is_strict_lock_sur_parole<L>
cl.owns_lock(m);
Models
// #include <boost/thread/lock_concepts.hpp> 

namespace boost
{

  template<typename Lock>
  class StrictLock;
}

A StrictLock is a lock that ensures that the associated mutex is locked during the lifetime of the lock.

A type L meets the StrictLock requirements if the following expressions are well-formed and have the specified semantics

  • L::mutex_type
  • is_strict_lock<L>
  • cl.owns_lock(m);

and BasicLockable<L::mutex_type>

where

  • cl denotes a value of type L const&,
  • m denotes a value of type L::mutex_type const*,

The type L::mutex_type denotes the mutex that is locked by this lock.

As the semantic "ensures that the associated mutex is locked during the lifetime of the lock. " can not be described by syntactic requirements a is_strict_lock_sur_parole trait must be specialized by the user defining the lock so that the following assertion is true:

is_strict_lock_sur_parole<L>::value == true

Return Type:

bool

Returns:

Whether the strict lock is locking the mutex m

Throws:

Nothing.

The following classes are models of StrictLock:

  • strict_lock: ensured by construction,
  • nested_strict_lock: "sur parole" as the user could use adopt_lock_t on unique_lock constructor overload without having locked the mutex,
  • boost::lock_guard: "sur parole" as the user could use adopt_lock_t constructor overload without having locked the mutex.

PrevUpHomeNext