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

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

#include <yarp/os/RecursiveMutex.h>

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

Definition at line 37 of file 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...
 

Constructor & Destructor Documentation

◆ RecursiveMutex()

RecursiveMutex::RecursiveMutex ( )

Constructor.

Definition at line 20 of file RecursiveMutex.cpp.

◆ ~RecursiveMutex()

RecursiveMutex::~RecursiveMutex ( )

Destructor.

Definition at line 25 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 30 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 35 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 46 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 40 of file RecursiveMutex.cpp.


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