recursive_timed_mutex Class

 

For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

Represents a timed mutex type. Objects of this type are used to enforce mutual exclusion by using time-limited blocking within a program. Unlike objects of type timed_mutex, the effect of calling locking methods for recursive_timed_mutex objects is well-defined.

class recursive_timed_mutex;

Public Constructors

NameDescription
recursive_timed_mutex::recursive_timed_mutex ConstructorConstructs a recursive_timed_mutex object that's not locked.
recursive_timed_mutex::~recursive_timed_mutex DestructorReleases any resources that are used by the recursive_timed_mutex object.

Public Methods

NameDescription
recursive_timed_mutex::lock MethodBlocks the calling thread until the thread obtains ownership of the mutex.
recursive_timed_mutex::try_lock MethodAttempts to obtain ownership of the mutex without blocking.
recursive_timed_mutex::try_lock_for MethodAttempts to obtain ownership of the mutex for a specified time interval.
recursive_timed_mutex::try_lock_until MethodAttempts to obtain ownership of the mutex until a specified time.
recursive_timed_mutex::unlock MethodReleases ownership of the mutex.

Header: mutex

Namespace: std

Blocks the calling thread until the thread obtains ownership of the mutex.

void lock();

Remarks

If the calling thread already owns the mutex, the method returns immediately, and the previous lock remains in effect.

Constructs a recursive_timed_mutex object that is not locked.

recursive_timed_mutex();

Releases any resources that are used by the recursive_timed_mutex object.

~recursive_timed_mutex();

Remarks

If the object is locked when the destructor runs, the behavior is undefined.

Attempts to obtain ownership of the mutex without blocking.

bool try_lock() noexcept;

Return Value

true if the method successfully obtained ownership of the mutex or if the calling thread already owns the mutex; otherwise, false.

Remarks

If the calling thread already owns the mutex, the function immediately returns true, and the previous lock remains in effect.

Attempts to obtain ownership of the mutex without blocking.

template <class Rep, class Period>
bool try_lock_for(const chrono::duration<Rep, Period>& Rel_time);

Parameters

Rel_time
A chrono::duration object that specifies the maximum amount of time that the method attempts to obtain ownership of the mutex.

Return Value

true if the method successfully obtains ownership of the mutex or if the calling thread already owns the mutex; otherwise, false.

Remarks

If the calling thread already owns the mutex, the method immediately returns true, and the previous lock remains in effect.

Attempts to obtain ownership of the mutex without blocking.

template <class Clock, class Duration>
bool try_lock_for(const chrono::time_point<Clock, Duration>& Abs_time);

bool try_lock_until(const xtime* Abs_time);

Parameters

Abs_time
A point in time that specifies the threshold after which the method no longer attempts to obtain ownership of the mutex.

Return Value

true if the method successfully obtains ownership of the mutex or if the calling thread already owns the mutex; otherwise, false.

Remarks

If the calling thread already owns the mutex, the method immediately returns true, and the previous lock remains in effect.

Releases ownership of the mutex.

void unlock();

Remarks

This method releases ownership of the mutex only after it is called as many times as lock, try_lock, try_lock_for, and try_lock_until have been called successfully on the recursive_timed_mutex object.

If the calling thread does not own the mutex, the behavior is undefined.

Header Files Reference
<mutex>

Show: