Free Electron
Public Member Functions | Private Attributes | List of all members
fe::StateCatalog::Atomic Class Reference

A locking mechanism to get cohesive state. More...

#include <StateCatalog.h>

Public Member Functions

 Atomic (sp< StateCatalog > a_spStateCatalog)
 Lock the StateCatalog. More...
 
 Atomic (sp< StateCatalog > a_spStateCatalog, I32 &a_rFlushCount, I32 a_microSleep, volatile BWORD &a_rKeepWaiting)
 Wait for a state change and then lock the StateCatalog. More...
 
 Atomic (sp< StateCatalog > a_spStateCatalog, I32 &a_rFlushCount, I32 a_microSleep=0)
 Wait for a state change and then lock the StateCatalog. More...
 
 ~Atomic (void)
 Unlock the StateCatalog. More...
 
Result getTypeName (String a_name, String &a_rTypeName) const
 Get state without additional locking (default property) More...
 
Result getTypeName (String a_name, String a_property, String &a_rTypeName) const
 Get state without additional locking. More...
 
template<class T >
Result getState (String a_name, T &a_rValue) const
 Get current state without additional locking. More...
 
template<class T >
Result getState (String a_name, String a_property, T &a_rValue) const
 Get current state without additional locking. More...
 
I32 spinCount (void) const
 Return an indication of how long it took for the state to change. More...
 
I32 locked (void) const
 Return TRUE if the lock was successful. More...
 
I32 serial (void) const
 Get the change count from when the Atomic was created. More...
 
I32 flushCount (void) const
 Get the count of incoming updates from when the Atomic was created. More...
 

Private Attributes

sp< StateCatalogm_spStateCatalog
 
BWORD m_locked
 
I32 m_spinCount
 
I32 m_serial
 
I32 m_flushCount
 

Detailed Description

A locking mechanism to get cohesive state.

While the Atomic persists, the StateCatalog will not update. The Atomic should be released as soon as possible.

Constructor & Destructor Documentation

◆ Atomic() [1/3]

fe::StateCatalog::Atomic::Atomic ( sp< StateCatalog a_spStateCatalog)
inline

Lock the StateCatalog.

◆ Atomic() [2/3]

fe::StateCatalog::Atomic::Atomic ( sp< StateCatalog a_spStateCatalog,
I32 &  a_rFlushCount,
I32  a_microSleep,
volatile BWORD &  a_rKeepWaiting 
)
inline

Wait for a state change and then lock the StateCatalog.

A previous flush count needs to be given as well as a spin counter.

This constructor will not return until the flush count of the StateCatalog exceeds the number sent. The reference value is set to the new flush count.

A pause time can be specified in micro seconds. If this value is zero, the spin lock is run at full speed.

The wait will stop if a_rKeepWaiting is or becomes zero.

◆ Atomic() [3/3]

fe::StateCatalog::Atomic::Atomic ( sp< StateCatalog a_spStateCatalog,
I32 &  a_rFlushCount,
I32  a_microSleep = 0 
)
inline

Wait for a state change and then lock the StateCatalog.

This version will always keep waiting.

◆ ~Atomic()

fe::StateCatalog::Atomic::~Atomic ( void  )
inline

Unlock the StateCatalog.

Member Function Documentation

◆ flushCount()

I32 fe::StateCatalog::Atomic::flushCount ( void  ) const
inline

Get the count of incoming updates from when the Atomic was created.

An increment of the flushCount corresponds to one flush() call at the sender. Multiple states can be updated on one flush.

◆ getState() [1/2]

template<class T >
Result fe::StateCatalog::Atomic::getState ( String  a_name,
T &  a_rValue 
) const
inline

Get current state without additional locking.

If the lock failed, this method will fail as well.

◆ getState() [2/2]

template<class T >
Result fe::StateCatalog::Atomic::getState ( String  a_name,
String  a_property,
T &  a_rValue 
) const
inline

Get current state without additional locking.

If the lock failed, this method will fail as well.

◆ getTypeName() [1/2]

Result fe::StateCatalog::Atomic::getTypeName ( String  a_name,
String a_rTypeName 
) const
inline

Get state without additional locking (default property)

If the lock failed, this method will fail as well.

◆ getTypeName() [2/2]

Result fe::StateCatalog::Atomic::getTypeName ( String  a_name,
String  a_property,
String a_rTypeName 
) const
inline

Get state without additional locking.

◆ locked()

I32 fe::StateCatalog::Atomic::locked ( void  ) const
inline

Return TRUE if the lock was successful.

If the a_keepWaiting argument changed becomes zero, the constructor can return without locking. If so, calls to getState will fail.

◆ serial()

I32 fe::StateCatalog::Atomic::serial ( void  ) const
inline

Get the change count from when the Atomic was created.

The StateCatalog keeps an serial count of how many state changes have occured.

◆ spinCount()

I32 fe::StateCatalog::Atomic::spinCount ( void  ) const
inline

Return an indication of how long it took for the state to change.

A spin count of zero means there was a change already in place before this constructor. Gauging different non-zero values may not be a useful metric.


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