Thread-safe counter. More...
#include <cmtkSafeCounter.h>

Public Member Functions | |
| SafeCounter (const unsigned int counter=0) | |
| Constructor. | |
| unsigned int | Get () const |
| Retrieve counter value. | |
| unsigned int | Increment () volatile |
| Increment and return new counter value. | |
| unsigned int | Decrement () volatile |
| Decrement and return new counter value. | |
Private Attributes | |
| unsigned int | m_Counter |
| The actual counter. | |
| MutexLock | m_Mutex |
| Mutex for thread-safe exclusive access to counter. | |
Thread-safe counter.
If the library is compiled without SMP support, then this class implements only an interface to a simple unsigned int counter. With SMP support, a mutex lock supplied by the MutexLock class is used to protect the counter from concurrent access of multiple threads.
Definition at line 54 of file cmtkSafeCounter.h.
| cmtk::SafeCounter::SafeCounter | ( | const unsigned int | counter = 0 ) |
[inline] |
Constructor.
Definition at line 58 of file cmtkSafeCounter.h.
| unsigned int cmtk::SafeCounter::Decrement | ( | ) | volatile [inline] |
Decrement and return new counter value.
Definition at line 71 of file cmtkSafeCounter.h.
| unsigned int cmtk::SafeCounter::Get | ( | ) | const [inline] |
Retrieve counter value.
Definition at line 61 of file cmtkSafeCounter.h.
| unsigned int cmtk::SafeCounter::Increment | ( | ) | volatile [inline] |
Increment and return new counter value.
Definition at line 64 of file cmtkSafeCounter.h.
Referenced by cmtk::SmartConstPointer< Study >::SmartConstPointer().
unsigned int cmtk::SafeCounter::m_Counter [private] |
The actual counter.
Definition at line 79 of file cmtkSafeCounter.h.
MutexLock cmtk::SafeCounter::m_Mutex [private] |
Mutex for thread-safe exclusive access to counter.
Definition at line 82 of file cmtkSafeCounter.h.
1.7.2