DUECA/DUSIME
Public Member Functions | List of all members
dueca::StateGuard Class Reference

Class that guards against race conditions. More...

Public Member Functions

 StateGuard (const char *name="anon", bool lockit=true)
 Constructor. More...
 
 ~StateGuard ()
 Destructor.
 
void accessState () const
 Request to enter the state. More...
 
void accessState (const char *txt) const
 Request to enter the state, with a description, use this form if you need more info at debugging. More...
 
void leaveState () const
 Release access to the state again. More...
 
void leaveState (const char *txt) const
 Release access to the state again, with a description, use this form if you need more info at debugging. More...
 
bool tryState () const
 Try to get access to the state. More...
 
bool tryState (const char *txt) const
 Try to get access to the state, with a description, use this form if you need more info at debugging. More...
 
const vstring & getName ()
 Return the name. More...
 

Detailed Description

Class that guards against race conditions.

DUECA internal use.

Constructor & Destructor Documentation

◆ StateGuard()

dueca::StateGuard::StateGuard ( const char *  name = "anon",
bool  lockit = true 
)

Constructor.

If lockit is true, it leaves the guard in a locked state, use leaveState() to get out of that.

Member Function Documentation

◆ accessState() [1/2]

void dueca::StateGuard::accessState ( ) const

Request to enter the state.

◆ accessState() [2/2]

void dueca::StateGuard::accessState ( const char *  txt) const

Request to enter the state, with a description, use this form if you need more info at debugging.

◆ leaveState() [1/2]

void dueca::StateGuard::leaveState ( ) const

Release access to the state again.

◆ leaveState() [2/2]

void dueca::StateGuard::leaveState ( const char *  txt) const

Release access to the state again, with a description, use this form if you need more info at debugging.

◆ tryState() [1/2]

bool dueca::StateGuard::tryState ( ) const

Try to get access to the state.

If free, you get it, otherwise this returns false.

◆ tryState() [2/2]

bool dueca::StateGuard::tryState ( const char *  txt) const

Try to get access to the state, with a description, use this form if you need more info at debugging.

◆ getName()

const vstring& dueca::StateGuard::getName ( )
inline

Return the name.


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