concept

TimedLockable

Timed lockable type

A timed lockable type is a Lockable type that supports try_lock_for and try_lock_until.

Types

The standard library defines the following TimedLockable types:
headertype
timed_mutex
recursive_timed_mutex

Requirements

A value m is of a TimedLockable 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.
m.try_lock_for(rel_time)
  • Effects: Attempts to acquire a lock for the current execution agent within the relative timeout specified by rel_time. The function shall not return within the timeout specified by rel_time unless it has obtained a lock on m for the current execution agent. 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.
m.try_lock_until(abs_time)
  • Effects: Attempts to acquire a lock for the current execution agent before the absolute timeout specified by abs_time. The function shall not return before the timeout specified by abs_time unless it has obtained a lock on m for the current execution agent. 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.
Where:
valuedescription
mA TimedLockable type
rel_timeA value of an instantiation of duration
abs_timeA value of an instantiation of time_point

See also