30 Thread support library [thread]

30.4 Mutual exclusion [thread.mutex]

30.4.2 Locks [thread.lock]

30.4.2.3 Class template shared_lock [thread.lock.shared]

30.4.2.3.2 shared_lock locking [thread.lock.shared.locking]

void lock();

Effects: As if by pm->lock_shared().

Postconditions: owns == true.

Throws: Any exception thrown by pm->lock_shared(). system_error when an exception is required ([thread.req.exception]).

Error conditions:

  • operation_not_permitted — if pm is nullptr.

  • resource_deadlock_would_occur — if on entry owns is true.

bool try_lock();

Effects: As if by pm->try_lock_shared().

Returns: The value returned by the call to pm->try_lock_shared().

Postconditions: owns == res, where res is the value returned by the call to pm->try_lock_shared().

Throws: Any exception thrown by pm->try_lock_shared(). system_error when an exception is required ([thread.req.exception]).

Error conditions:

  • operation_not_permitted — if pm is nullptr.

  • 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);

Effects: As if by pm->try_lock_shared_until(abs_time).

Returns: The value returned by the call to pm->try_lock_shared_until(abs_time).

Postconditions: owns == res, where res is the value returned by the call to pm->try_lock_shared_until(abs_time).

Throws: Any exception thrown by pm->try_lock_shared_until(abs_time). system_error when an exception is required ([thread.req.exception]).

Error conditions:

  • operation_not_permitted — if pm is nullptr.

  • 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);

Effects: As if by pm->try_lock_shared_for(rel_time).

Returns: The value returned by the call to pm->try_lock_shared_for(rel_time).

Postconditions: owns == res, where res is the value returned by the call to pm->try_lock_shared_for(rel_time).

Throws: Any exception thrown by pm->try_lock_shared_for(rel_time). system_error when an exception is required ([thread.req.exception]).

Error conditions:

  • operation_not_permitted — if pm is nullptr.

  • resource_deadlock_would_occur — if on entry owns is true.

void unlock();

Effects: As if by pm->unlock_shared().

Postconditions: owns == false.

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

Error conditions:

  • operation_not_permitted — if on entry owns is false.