Orocos Real-Time Toolkit  2.9.0
Public Member Functions | Protected Attributes | Friends | List of all members
RTT::os::Mutex Class Reference

An object oriented wrapper around a non recursive mutex. More...

#include <rtt/os/Mutex.hpp>

Inheritance diagram for RTT::os::Mutex:
RTT::os::MutexInterface

Public Member Functions

 Mutex ()
 Initialize a Mutex. More...
 
virtual ~Mutex ()
 Destroy a Mutex. More...
 
virtual void lock ()
 
virtual void unlock ()
 
virtual bool trylock ()
 Try to lock this mutex. More...
 
virtual bool timedlock (Seconds s)
 Lock this mutex, but don't wait longer for the lock than the specified timeout. More...
 
virtual void lock_shared ()
 
virtual void unlock_shared ()
 
virtual bool trylock_shared ()
 
virtual bool timedlock_shared (Seconds)
 

Protected Attributes

rt_mutex_t m
 

Friends

class Condition
 

Detailed Description

An object oriented wrapper around a non recursive mutex.

A mutex can only be unlock()'ed, by the thread which lock()'ed it. A trylock is a non blocking lock action which fails or succeeds.

Warning
Mutex instances should only be created in soft realtime, since the initialisation of a mutex can not be done in hard realtime.
See also
MutexLock, MutexTryLock, MutexTimedLock, MutexRecursive

Definition at line 92 of file Mutex.hpp.

Constructor & Destructor Documentation

RTT::os::Mutex::Mutex ( )
inline

Initialize a Mutex.

Definition at line 102 of file Mutex.hpp.

References rtos_mutex_init().

virtual RTT::os::Mutex::~Mutex ( )
inlinevirtual

Destroy a Mutex.

If the Mutex is still locked, the RTOS will not be asked to clean up its resources.

Definition at line 112 of file Mutex.hpp.

References rtos_mutex_destroy().

Member Function Documentation

virtual void RTT::os::Mutex::lock ( )
inlinevirtual

Implements RTT::os::MutexInterface.

Definition at line 120 of file Mutex.hpp.

References rtos_mutex_lock().

Referenced by timedlock().

virtual void RTT::os::MutexInterface::lock_shared ( )
inlinevirtualinherited

Reimplemented in RTT::os::SharedMutex.

Definition at line 75 of file Mutex.hpp.

Referenced by RTT::os::SharedMutexLock::SharedMutexLock().

virtual bool RTT::os::Mutex::timedlock ( Seconds  s)
inlinevirtual

Lock this mutex, but don't wait longer for the lock than the specified timeout.

Parameters
sThe maximum time to wait before aqcuiring the lock.
Returns
true when the locking succeeded, false otherwise

Implements RTT::os::MutexInterface.

Definition at line 149 of file Mutex.hpp.

References lock(), rtos_mutex_trylock_for(), and RTT::Seconds_to_nsecs().

virtual bool RTT::os::MutexInterface::timedlock_shared ( Seconds  )
inlinevirtualinherited

Reimplemented in RTT::os::SharedMutex.

Definition at line 78 of file Mutex.hpp.

virtual bool RTT::os::Mutex::trylock ( )
inlinevirtual

Try to lock this mutex.

Returns
true when the locking succeeded, false otherwise

Implements RTT::os::MutexInterface.

Definition at line 135 of file Mutex.hpp.

References rtos_mutex_trylock().

virtual bool RTT::os::MutexInterface::trylock_shared ( )
inlinevirtualinherited

Reimplemented in RTT::os::SharedMutex.

Definition at line 77 of file Mutex.hpp.

virtual void RTT::os::Mutex::unlock ( )
inlinevirtual

Implements RTT::os::MutexInterface.

Definition at line 125 of file Mutex.hpp.

References rtos_mutex_unlock().

virtual void RTT::os::MutexInterface::unlock_shared ( )
inlinevirtualinherited

Reimplemented in RTT::os::SharedMutex.

Definition at line 76 of file Mutex.hpp.

Friends And Related Function Documentation

friend class Condition
friend

Definition at line 94 of file Mutex.hpp.

Member Data Documentation

rt_mutex_t RTT::os::Mutex::m
protected

Definition at line 97 of file Mutex.hpp.

Referenced by RTT::os::Condition::wait(), and RTT::os::Condition::wait_until().


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