FARGOS/VISTA Object Management Environment Core  ..
FARGOS/VISTA Object Management Environment Core Table of Contents

Generic mutex implementation that supports timing statistics. More...

#include <timed_mutex.hpp>

Classes

class  TimedMutexStatistics
 Statistics for a TimedMutex object. More...
 

Public Member Functions

 TimedMutex (const char *lockName, SharedMemoryVariableNode *parentNode, bool recursive=false)
 Implements generic mutex with performance counters. More...
 
 TimedMutex (const char *lockName=nullptr, SharedMemoryVariableManager *mgr=&DEFAULT_sharedMemoryVariableManager, bool recursive=false)
 Implements generic mutex with performance counters. More...
 
 ~TimedMutex ()
 
int64_t lock (const char *place=nullptr) OME_ALWAYS_INLINE
 Lock the mutex. More...
 
int64_t untimedLock () OME_ALWAYS_INLINE
 Lock the mutex, but maintain neither usage nor timing statistics. More...
 
int64_t unlock ()
 Release a previously locked mutex. More...
 
int64_t untimedUnlock () OME_ALWAYS_INLINE
 Unlock the mutex, but maintain neither usage nor timing statistics. More...
 
OME_MUTEX_TYPEmutex_address () OME_ALWAYS_INLINE NONNULL_RETURN
 Get address of underlying native mutex. More...
 
const char * getMutexName () const NONNULL_RETURN
 Return name of mutex. More...
 
uint64_t getThreadIdOfCurrentOwner () const OME_ALWAYS_INLINE
 Return thread id of thread holding lock. More...
 

Protected Member Functions

int64_t acquireLock ()
 

Protected Attributes

TimedMutexStatisticsstatistics
 
uint64_t obtainedAt
 
OME_MUTEX_TYPE mutex
 

Friends

class TimedCondition
 

Detailed Description

Generic mutex implementation that supports timing statistics.

Constructor & Destructor Documentation

◆ TimedMutex() [1/2]

TimedMutex::TimedMutex ( const char *  lockName,
SharedMemoryVariableNode parentNode,
bool  recursive = false 
)
explicit

Implements generic mutex with performance counters.

Parameters
lockNameis a user-provided name to label the lock. If a null pointer, no statistics will be maintained.
parentNodespecifies a root under which any SharedMemoryVariable counters should be registered.
recursiveindicates if a recursive lock is desired.

References mutex, obtainedAt, PTHREAD_MUTEX_RECURSIVE, and statistics.

◆ TimedMutex() [2/2]

TimedMutex::TimedMutex ( const char *  lockName = nullptr,
SharedMemoryVariableManager mgr = &DEFAULT_sharedMemoryVariableManager,
bool  recursive = false 
)
explicit

Implements generic mutex with performance counters.

Parameters
lockNameis a user-provided name to label the lock. If a null pointer, no statistics will be maintained.
mgrspecifies SharedMemoryVariableManager to which the counters should be registered.
recursiveindicates if a recursive lock is desired.

References mutex, obtainedAt, PTHREAD_MUTEX_RECURSIVE, and statistics.

◆ ~TimedMutex()

TimedMutex::~TimedMutex ( )

References mutex, and statistics.

Member Function Documentation

◆ acquireLock()

◆ getMutexName()

const char* TimedMutex::getMutexName ( ) const
inline

Return name of mutex.

Return values
TimedMutexwill be returned if the name was never set; this will never return a null pointer.

References SharedMemoryVariable::getName(), TimedMutex::TimedMutexStatistics::namingNode, and statistics.

◆ getThreadIdOfCurrentOwner()

uint64_t TimedMutex::getThreadIdOfCurrentOwner ( ) const
inline

Return thread id of thread holding lock.

Return values
0indicates either no thread is holding the lock or it was not remembered because statistics are not available.

References TimedMutex::TimedMutexStatistics::lockHeldBy, and statistics.

◆ lock()

int64_t TimedMutex::lock ( const char *  place = nullptr)
inline

Lock the mutex.

Parameters
placespecifies the location in readable form.
Note
See LOCK_HERE().
Returns
The number of nanoseconds required to obtain the lock is returned.
Note
Timings are still provided even if statistics are not maintained. Use untimedLock() for the variant which does not provide any timing data.

References acquireLock(), TimedMutex::TimedMutexStatistics::lockLocation, and statistics.

Referenced by TimedCondition::lock(), TimedCondition::waitForCondition(), and TimedCondition::waitForConditionOrUntil().

◆ mutex_address()

OME_MUTEX_TYPE* TimedMutex::mutex_address ( )
inline

Get address of underlying native mutex.

References mutex.

Referenced by TimedCondition::mutex_address(), TimedCondition::waitForCondition(), and TimedCondition::waitForConditionOrUntil().

◆ unlock()

◆ untimedLock()

int64_t TimedMutex::untimedLock ( )
inline

Lock the mutex, but maintain neither usage nor timing statistics.

Return values
0is always returned.

References mutex.

Referenced by TimedCondition::untimedLock(), and TimedCondition::untimedUnlock().

◆ untimedUnlock()

int64_t TimedMutex::untimedUnlock ( )
inline

Unlock the mutex, but maintain neither usage nor timing statistics.

Return values
0is always returned.

References mutex.

Friends And Related Function Documentation

◆ TimedCondition

friend class TimedCondition
friend

Member Data Documentation

◆ mutex

◆ obtainedAt

uint64_t TimedMutex::obtainedAt
protected

Referenced by acquireLock(), TimedMutex(), and unlock().

◆ statistics


The documentation for this class was generated from the following files:
Generated: Tue Jul 28 2020 16:03:27
Support Information