33 Thread support library [thread]

33.4 Mutual exclusion [thread.mutex]

33.4.4 Locks [thread.lock]

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

33.4.4.4.1 shared_­lock constructors, destructor, and assignment [thread.lock.shared.cons]

shared_lock() noexcept;
Effects: Constructs an object of type shared_­lock.
Postconditions: pm == nullptr and owns == false.
explicit shared_lock(mutex_type& m);
Requires: The calling thread does not own the mutex for any ownership mode.
Effects: Constructs an object of type shared_­lock and calls m.lock_­shared().
Postconditions: pm == addressof(m) and owns == true.
shared_lock(mutex_type& m, defer_lock_t) noexcept;
Effects: Constructs an object of type shared_­lock.
Postconditions: pm == addressof(m) and owns == false.
shared_lock(mutex_type& m, try_to_lock_t);
Requires: The calling thread does not own the mutex for any ownership mode.
Effects: Constructs an object of type shared_­lock and calls m.try_­lock_­shared().
Postconditions: pm == addressof(m) and owns == res where res is the value returned by the call to m.try_­lock_­shared().
shared_lock(mutex_type& m, adopt_lock_t);
Requires: The calling thread has shared ownership of the mutex.
Effects: Constructs an object of type shared_­lock.
Postconditions: pm == addressof(m) and owns == true.
template<class Clock, class Duration> shared_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
Requires: The calling thread does not own the mutex for any ownership mode.
Effects: Constructs an object of type shared_­lock and calls m.try_­lock_­shared_­until(abs_­time).
Postconditions: pm == addressof(m) and owns == res where res is the value returned by the call to m.try_­lock_­shared_­until(abs_­time).
template<class Rep, class Period> shared_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time);
Requires: The calling thread does not own the mutex for any ownership mode.
Effects: Constructs an object of type shared_­lock and calls m.try_­lock_­shared_­for(rel_­time).
Postconditions: pm == addressof(m) and owns == res where res is the value returned by the call to m.try_­lock_­shared_­for(rel_­time).
~shared_lock();
Effects: If owns calls pm->unlock_­shared().
shared_lock(shared_lock&& sl) noexcept;
Postconditions: pm == sl_­p.pm and owns == sl_­p.owns (where sl_­p is the state of sl just prior to this construction), sl.pm == nullptr and sl.owns == false.
shared_lock& operator=(shared_lock&& sl) noexcept;
Effects: If owns calls pm->unlock_­shared().
Postconditions: pm == sl_­p.pm and owns == sl_­p.owns (where sl_­p is the state of sl just prior to this assignment), sl.pm == nullptr and sl.owns == false.