32 Thread support library [thread]

32.5 Mutual exclusion [thread.mutex]

32.5.5 Locks [thread.lock]

32.5.5.5 Class template shared_­lock [thread.lock.shared]

32.5.5.5.3 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().
Postconditions: owns == res, where res is the value returned by the call to pm->try_­lock_­shared().
Returns: 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).
Postconditions: owns == res, where res is the value returned by the call to pm->try_­lock_­shared_­until(abs_­time).
Returns: 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).
Postconditions: owns == res, where res is the value returned by the call to pm->try_­lock_­shared_­for(rel_­time).
Returns: 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.