Skip to content

timed_named_mutex try_lock

Alairion edited this page May 8, 2021 · 2 revisions

Functions

(1) bool try_lock();
  1. Tries to lock the mutex. If it is already owned by another thread, this function still returns immediately.

Parameters

None.

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 of 0ms
    On Posix systems, calls pthread_mutex_trylock
Clone this wiki locally