Std::Recursive_Timed_Mutex::Try_Lock_For Member Function

Attempts to acquire a lock on a std::recursive_timed_mutex object for the current thread.

Declaration

template<typename Rep,typename Period>
bool try_lock_for(
    std::chrono::duration<Rep,Period> const& relative_time);

Effects

Attempts to acquire a lock on *this for the calling thread within the time specified by relative_time. If relative_time.count() is zero or negative, the call will return immediately, as if it was a call to try_lock(). Otherwise, the call blocks until either the lock has been acquired or the time period specified by relative_time has elapsed.

Returns

true if a lock was obtained for the calling thread, false otherwise.

Postconditions

*this is locked by the calling ...

Get C++ Concurrency in Action now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.