O'Reilly logo

C++ Concurrency in Action: Practical Multithreading by Anthony Williams

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required