Documentation Home

Construct a std::shared_lock instance associated with the supplied mutex and tries to acquire a shared-ownership lock on that mutex.

template<typename Rep,typename Period>
shared_lock(
    mutex_type& m,
    std::chrono::duration<Rep,Period> const&
    relative_time);

Preconditions:

The Mutex type used to instantiate std::shared_lock must meet the TimedLockable requirements.

Effects:

Constructs a std::shared_lock instance that references the supplied mutex. Calls m.try_lock_shared_for(relative_time).

Throws:

Nothing.

Postcondition:

this->owns_lock() returns the result of the m.try_lock_shared_for() call, this->mutex()==&m.

Header

#include <shared_mutex>

See Also