YARP
Yet Another Robot Platform
yarp::os::RecursiveMutex Class Reference

RecursiveMutex offers exclusive, recursive ownership semantics: More...

#include <yarp/os/RecursiveMutex.h>

Classes

class  Private
 

Public Member Functions

 RecursiveMutex ()
 Constructor. More...
 
 ~RecursiveMutex ()
 Destructor. More...
 
void lock ()
 Lock the associated resource, waiting if the resource is busy. More...
 
bool try_lock ()
 Lock the associated resource if it is free. More...
 
void unlock ()
 Unlock the associated resource thus freeing waiting threads. More...
 
bool tryLock ()
 Lock the associated resource if it is free. More...
 

Detailed Description

RecursiveMutex offers exclusive, recursive ownership semantics:

  • A calling thread owns a RecursiveMutex for a period of time that starts when it successfully calls either lock or tryLock. During this period, the thread may make additional calls to lock or tryLock. The period of ownership ends when the thread makes a matching number of calls to unlock.
  • When a thread owns a RecursiveMutex, all other threads will block (for calls to lock) or receive a false return value (for tryLock) if they attempt to claim ownership of the RecursiveLock. The behavior of a program is undefined if a RecursiveMutex is destroyed while still owned by some thread. The behavior of a program is undefined if a RecursiveMutex is unlocked by a thread which is not currently owning the RecursiveMutex
Deprecated:
since YARP 3.3. Use std::recursive_mutex instead.

Definition at line 43 of file RecursiveMutex.h.

Constructor & Destructor Documentation

◆ RecursiveMutex()

RecursiveMutex::RecursiveMutex ( )

Constructor.

Definition at line 23 of file RecursiveMutex.cpp.

◆ ~RecursiveMutex()

RecursiveMutex::~RecursiveMutex ( )

Destructor.

Definition at line 28 of file RecursiveMutex.cpp.

Member Function Documentation

◆ lock()

void RecursiveMutex::lock ( )

Lock the associated resource, waiting if the resource is busy.

If the thread which is currently owning the resource calls this function, it will not block, and a reference count will be increased Thu number of calls to lock() must be balanced by the same number of calls to unlock()

Definition at line 33 of file RecursiveMutex.cpp.

◆ try_lock()

bool RecursiveMutex::try_lock ( )

Lock the associated resource if it is free.

See also
RecursiveLock::lock() for more detailed description
Returns
true if the associated resource was successfully locked. False otherwise

Definition at line 38 of file RecursiveMutex.cpp.

◆ tryLock()

bool RecursiveMutex::tryLock ( )

Lock the associated resource if it is free.

See also
RecursiveLock::lock() for more detailed description
Returns
true if the associated resource was successfully locked. False otherwise
Deprecated:
since YARP 3.0.0. Use try_lock() instead.

Definition at line 48 of file RecursiveMutex.cpp.

◆ unlock()

void RecursiveMutex::unlock ( )

Unlock the associated resource thus freeing waiting threads.

If the resource is not currently locked by the calling thread, the behavior is undefined.

Definition at line 43 of file RecursiveMutex.cpp.


The documentation for this class was generated from the following files: