Attempt to acquire a lock on a std::recursive_timed_mutex object
for the current thread.
template<typename Clock,typename Duration> bool try_lock_until( std::chrono::time_point<Clock,Duration> const& absolute_time);
- Effects:
Attempts to acquire a lock on
*thisfor the calling thread before the time specified byabsolute_time. Ifabsolute_time<=Clock::now()on entry then the call will return immediately, as if it was a call totry_lock(). Otherwise, the call shall block until either the lock has been acquired orClock::now()returns a time equal to or later thanabsolute_time.- Returns:
trueif a lock was obtained for the calling thread,falseotherwise.- Postconditions:
*thisis locked by the calling thread if the function returnstrue.- Throws:
Nothing.
- Note:
If the calling thread already holds the lock on
*this, the function returnstrueand the count of locks on*thisheld by the calling thread is increased by one. If the current thread does not already hold a lock on*this, the function may fail to acquire the lock (and returnfalse) even if no other thread holds a lock on*this. There is no guarantee as to how long the calling thread will be blocked for, only that if the function returnsfalsethenClock::now()returned a time equal to or later thanabsolute_timeat the point at which the thread became unblocked.- Throws:
Nothing
Header
#include <mutex>