Skip to content

timed_named_mutex try_lock_until

Alairion edited this page May 8, 2021 · 2 revisions

nes::timed_named_mutex::try_lock_until

Functions

    template<class Clock, class Duration>
(1) bool try_lock_until(const std::chrono::time_point<Clock, Duration>& time_point);
  1. Tries to lock the mutex. Blocks until specified time point is reached or the lock is acquired.

Parameters

Name Description
time_point A std::chrono::time_point representing the minimum time point to wait until

Return value

  1. Returns true if the mutex was acquired, false otherwise.

Preconditions

  1. The calling thread must not own the mutex.

Exceptions

  1. Throws a std::runtime_error if the lock operation fails.

Implementation details

  1. On Windows, calls WaitForSingleObject with a timeout equal to the conversion of the duration to milliseconds (rounded down) of the time point subtracted by the current time. On Posix systems, calls pthread_mutex_timedlock
Clone this wiki locally