concept

Lockable

Lockable type (mutex type)

A lockable type (also known as mutex type) is a BasicLockable type that supports try_lock.

Types

The standard library defines the following Lockable types:
headertype
<mutex>mutex
recursive_mutex
timed_mutex
recursive_timed_mutex

Requirements

A value m is of a Lockable type if the following expressions are well-formed:
m.lock()
  • Effects: Block until a lock can be acquired for the current execution agent. If an exception is thrown, then a lock shall not have been acquired for the current execution agent.
m.unlock()
  • Requires: The current execution agent shall hold a lock on m.
  • Effects: Releases a lock on m held by the current execution agent.
  • Throws: Nothing.
m.try_lock()
  • Effects: Attempts to acquire a lock for the current execution agent without blocking. If an exception is thrown, then a lock shall not have been acquired for the current execution agent.
  • Return type: bool
  • Returns: true if the lock was acquired, false otherwise.

See also