Privacy
An open-source, flexible 3D physical simulation framework
mars::utils::Mutex Class Reference

#include <Mutex.h>

Public Member Functions

 Mutex (const MutexType &mutexType=MUTEX_TYPE_NORMAL)
 
 ~Mutex ()
 
MutexError lock ()
 locks the Mutex More...
 
MutexError tryLock ()
 tries to lock the mutex. More...
 
MutexError unlock ()
 
MutexType getMutexType () const
 

Private Member Functions

 Mutex (const Mutex &)
 
Mutexoperator= (const Mutex &)
 
void * getHandle ()
 

Private Attributes

PthreadMutexWrappermyMutex
 
MutexType mutexType
 

Friends

class WaitCondition
 

Detailed Description

Definition at line 47 of file Mutex.h.

Constructor & Destructor Documentation

◆ Mutex() [1/2]

mars::utils::Mutex::Mutex ( const MutexType mutexType = MUTEX_TYPE_NORMAL)
explicit

Definition at line 35 of file Mutex.cpp.

◆ ~Mutex()

mars::utils::Mutex::~Mutex ( )

Definition at line 56 of file Mutex.cpp.

◆ Mutex() [2/2]

mars::utils::Mutex::Mutex ( const Mutex )
private

Member Function Documentation

◆ getHandle()

void * mars::utils::Mutex::getHandle ( )
private

Definition at line 109 of file Mutex.cpp.

◆ getMutexType()

MutexType mars::utils::Mutex::getMutexType ( ) const
inline

Definition at line 77 of file Mutex.h.

◆ lock()

MutexError mars::utils::Mutex::lock ( )

locks the Mutex

Returns
MUTEX_ERROR_NO_ERROR if the Mutex was successfully locked. Otherwise depending on the error one of MUTEX_ERROR_NO_VALID_MUTEX, MUTEX_ERROR_RECURSIVE_LIMIT, MUTEX_ERROR_DEADLOCK, or MUTEX_ERROR_UNKNOWN is returned.

Definition at line 61 of file Mutex.cpp.

◆ operator=()

Mutex& mars::utils::Mutex::operator= ( const Mutex )
private

◆ tryLock()

MutexError mars::utils::Mutex::tryLock ( )

tries to lock the mutex.

Returns
MUTEX_ERROR_NO_ERROR if the Mutex was successfully locked. MUTEX_ERROR_BUSY if the mutex couldn't be locked because it is already locked. Otherwise depending on the error one of MUTEX_ERROR_NO_VALID_MUTEX, MUTEX_ERROR_RECURSIVE_LIMIT, or MUTEX_ERROR_UNKNOWN is returned.

This method tries to lock the Mutex but does not block to do so. If the mutex is not held by anyone it is locked and MUTEX_ERROR_NO_ERROR is returned. If the mutex is currently in locked state MUTEX_ERROR_BUSY is returned.

Definition at line 93 of file Mutex.cpp.

◆ unlock()

MutexError mars::utils::Mutex::unlock ( )

Definition at line 77 of file Mutex.cpp.

Friends And Related Function Documentation

◆ WaitCondition

friend class WaitCondition
friend

Definition at line 90 of file Mutex.h.

Member Data Documentation

◆ mutexType

MutexType mars::utils::Mutex::mutexType
private

Definition at line 88 of file Mutex.h.

◆ myMutex

PthreadMutexWrapper* mars::utils::Mutex::myMutex
private

Definition at line 87 of file Mutex.h.


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