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

Generic condition variable for use with the TimedMutex class. More...

#include <timed_mutex.hpp>

Classes

class  TimedConditionStatistics
 Statistics for a TimedCondition object. More...
 

Public Member Functions

 TimedCondition (TimedMutex *m, const char *conditionName, SharedMemoryVariableNode *parentNode) NONNULL_CLASS_PARAMETERS(2)
 Implements generic condition variable with performance counters. More...
 
 TimedCondition (TimedMutex *m, const char *conditionName=nullptr, SharedMemoryVariableManager *mgr=&DEFAULT_sharedMemoryVariableManager) NONNULL_CLASS_PARAMETERS(2)
 Implements generic condition variable with performance counters. More...
 
 ~TimedCondition ()
 
TimedMutexgetMutex () const OME_ALWAYS_INLINE NONNULL_RETURN
 Return address of mutex object associated with the condition variable. More...
 
OME_CONDITION_TYPEcondition_address () OME_ALWAYS_INLINE NONNULL_RETURN
 Get address of underlying native condition variable. More...
 
int64_t waitForCondition (const char *waitingHere=nullptr)
 Wait indefinitely for the condition to be posted. More...
 
int64_t waitForConditionOrUntil (const struct timespec *timeout, const char *waitingHere=nullptr) NONNULL_CLASS_PARAMETERS(2)
 Wait for the condition to be posted or until a specified point in time. More...
 
int postCondition ()
 Notify any sleeping threads that the condition has occurred. More...
 
bool isSleeping () const OME_ALWAYS_INLINE
 Return a Boolean indication of whether or not a thread is sleeping. More...
 
const char * getConditionName () const NONNULL_RETURN
 Return name of condition variable. More...
 
int64_t lock (const char *place=nullptr) OME_ALWAYS_INLINE
 Convenience routine to lock the associated mutex. More...
 
int64_t untimedLock () OME_ALWAYS_INLINE
 Convenience routine to lock the associated mutex, but maintain neither usage nor timing statistics. More...
 
int64_t unlock () OME_ALWAYS_INLINE
 Convenience routine to release previously locked mutex associated with the condition variable. More...
 
int64_t untimedUnlock () OME_ALWAYS_INLINE
 Convenience routine to unlock the mutex associated with the condition variable, but maintain neither usage nor timing statistics. More...
 
OME_MUTEX_TYPEmutex_address () OME_ALWAYS_INLINE NONNULL_RETURN
 Convenience routine to get address of underlying native mutex that is associated with the condition variable. More...
 

Protected Attributes

TimedConditionStatisticsstatistics
 
uint64_t startedAt
 
TimedMutexmutex
 
OME_CONDITION_TYPE condition
 
bool active
 

Detailed Description

Generic condition variable for use with the TimedMutex class.

Constructor & Destructor Documentation

◆ TimedCondition() [1/2]

TimedCondition::TimedCondition ( TimedMutex m,
const char *  conditionName,
SharedMemoryVariableNode parentNode 
)
explicit

Implements generic condition variable with performance counters.

Parameters
mis an existing mutex to be associated with the condition variable. It is expected to be locked before calling waitForCondition() or waitForConditionOrUntil().
conditionNameis a user-provided name to label the condition. If a null pointer, no statistics will be maintained.
parentNodespecifies a root under which any SharedMemoryVariable counters should be registered.

References active, condition, mutex, NULL, startedAt, and statistics.

◆ TimedCondition() [2/2]

TimedCondition::TimedCondition ( TimedMutex m,
const char *  conditionName = nullptr,
SharedMemoryVariableManager mgr = &DEFAULT_sharedMemoryVariableManager 
)
explicit

Implements generic condition variable with performance counters.

Parameters
mis an existing mutex to be associated with the condition variable. It is expected to be locked before calling waitForCondition() or waitForConditionOrUntil().
conditionNameis a user-provided name to label the condition. If a null pointer, no statistics will be maintained.
mgrspecifies SharedMemoryVariableManager to which the counters should be registered.

References active, condition, mutex, NULL, startedAt, and statistics.

◆ ~TimedCondition()

TimedCondition::~TimedCondition ( )

References condition, and statistics.

Member Function Documentation

◆ condition_address()

OME_CONDITION_TYPE* TimedCondition::condition_address ( )
inline

Get address of underlying native condition variable.

References condition.

◆ getConditionName()

const char* TimedCondition::getConditionName ( ) const
inline

Return name of condition variable.

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

References SharedMemoryVariable::getName(), TimedCondition::TimedConditionStatistics::namingNode, and statistics.

◆ getMutex()

TimedMutex* TimedCondition::getMutex ( ) const
inline

Return address of mutex object associated with the condition variable.

References mutex.

◆ isSleeping()

bool TimedCondition::isSleeping ( ) const
inline

Return a Boolean indication of whether or not a thread is sleeping.

References active.

Referenced by IO_Processor::noteDataToProcess().

◆ lock()

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

Convenience routine to lock the associated mutex.

Parameters
placespecifies the location in readable form.
Note
See LOCK_HERE().
Returns
The number of nanoseconds required to obtain the lock is returned.

References TimedMutex::lock(), and mutex.

◆ mutex_address()

OME_MUTEX_TYPE* TimedCondition::mutex_address ( )
inline

Convenience routine to get address of underlying native mutex that is associated with the condition variable.

References mutex, and TimedMutex::mutex_address().

◆ postCondition()

int TimedCondition::postCondition ( )

Notify any sleeping threads that the condition has occurred.

Note
Normally the associated mutex should have been locked, but if one is aware of what they are doing, it is possible to use this routine without having locked the mutex.
Return values
0is always returned

References condition, statistics, and TimedCondition::TimedConditionStatistics::totalPostEvents.

Referenced by IO_Processor::noteDataToProcess().

◆ unlock()

int64_t TimedCondition::unlock ( )
inline

Convenience routine to release previously locked mutex associated with the condition variable.

Returns
The duration in nanoseconds that the lock was held is returned.

References mutex, and TimedMutex::unlock().

◆ untimedLock()

int64_t TimedCondition::untimedLock ( )
inline

Convenience routine to lock the associated mutex, but maintain neither usage nor timing statistics.

Return values
0is always returned.

References mutex, and TimedMutex::untimedLock().

◆ untimedUnlock()

int64_t TimedCondition::untimedUnlock ( )
inline

Convenience routine to unlock the mutex associated with the condition variable, but maintain neither usage nor timing statistics.

Return values
0is always returned.

References mutex, and TimedMutex::untimedLock().

◆ waitForCondition()

int64_t TimedCondition::waitForCondition ( const char *  waitingHere = nullptr)

◆ waitForConditionOrUntil()

int64_t TimedCondition::waitForConditionOrUntil ( const struct timespec *  timeout,
const char *  waitingHere = nullptr 
)

Wait for the condition to be posted or until a specified point in time.

Parameters
timeoutspecifies a point in time after which the routine will return. This is not a difference in time relative to the invocation of the function call, but instead an absolute point in time.
waitingHerespecifies the location of the call. See WAIT_HERE().
Return values
Theduration of the wait in nanoseconds is returned.
Note
Timings are still provided even if statistics are not maintained.

References active, clock_gettime_via_tick(), condition, get_CPU_ticks(), TimedMutex::lock(), mutex, TimedMutex::mutex_address(), startedAt, statistics, TimedCondition::TimedConditionStatistics::totalWaitTicks, TimedMutex::unlock(), TimedCondition::TimedConditionStatistics::waitCompletedAt, TimedCondition::TimedConditionStatistics::waitLocation, TimedCondition::TimedConditionStatistics::waitsCompleted, TimedCondition::TimedConditionStatistics::waitsStarted, and TimedCondition::TimedConditionStatistics::waitStartedAt.

Member Data Documentation

◆ active

bool TimedCondition::active
protected

◆ condition

◆ mutex

◆ startedAt

uint64_t TimedCondition::startedAt
protected

◆ statistics


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