30 Thread support library [thread]

30.4 Mutual exclusion [thread.mutex]

30.4.2 Locks [thread.lock]

30.4.2.2 Class template unique_lock [thread.lock.unique]

30.4.2.2.2 unique_lock locking [thread.lock.unique.locking]

void lock();

Effects: pm->lock()

Postcondition: owns == true

Throws: Any exception thrown by pm->lock(). system_error if an exception is required ([thread.req.exception]). system_error with an error condition of operation_not_permitted if pm is 0. system_error with an error condition of resource_deadlock_would_occur if on entry owns is true.

bool try_lock();

Requires: The supplied Mutex shall meet the Lockable requirements ([thread.req.lockable.req]).

Effects: pm->try_lock()

Returns: The value returned by the call to try_lock().

Postcondition: owns == res, where res is the value returned by the call to try_lock().

Throws: Any exception thrown by pm->try_lock(). system_error if an exception is required ([thread.req.exception]). system_error with an error condition of operation_not_permitted if pm is 0. system_error with an error condition of resource_deadlock_would_occur if on entry owns is true.

template <class Clock, class Duration> bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);

Requires: The supplied Mutex type shall meet the TimedLockable requirements ([thread.req.lockable.timed]).

Effects: pm->try_lock_until(abs_time)

Returns: The value returned by the call to try_lock_until(abs_time).

Postcondition: owns == res, where res is the value returned by the call to try_lock_until(abs_time).

Throws: Any exception thrown by pm->try_lock_until(). system_error if an exception is required ([thread.req.exception]). system_error with an error condition of operation_not_permitted if pm is 0. system_error with an error condition of resource_deadlock_would_occur if on entry owns is true.

template <class Rep, class Period> bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);

Requires: The supplied Mutex type shall meet the TimedLockable requirements ([thread.req.lockable.timed]).

Effects: pm->try_lock_for(rel_time).

Returns: The value returned by the call to try_lock_until(rel_time).

Postcondition: owns == res, where res is the value returned by the call to try_lock_for(rel_time).

Throws: Any exception thrown by pm->try_lock_for(). system_error if an exception is required ([thread.req.exception]). system_error with an error condition of operation_not_permitted if pm is 0. system_error with an error condition of resource_deadlock_would_occur if on entry owns is true.

void unlock();

Effects: pm->unlock()

Postcondition: owns == false

Throws: system_error when an exception is required ([thread.req.exception]).

Error conditions:

  • operation_not_permitted — if on entry owns is false.