Public Member Functions | Private Attributes

cmtk::SafeCounter Class Reference
[cmtkSystem Library]

Thread-safe counter. More...

#include <cmtkSafeCounter.h>

Collaboration diagram for cmtk::SafeCounter:
Collaboration graph
[legend]

List of all members.

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.

Detailed Description

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.


Constructor & Destructor Documentation

cmtk::SafeCounter::SafeCounter ( const unsigned int  counter = 0 ) [inline]

Constructor.

Definition at line 58 of file cmtkSafeCounter.h.


Member Function Documentation

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().


Member Data Documentation

unsigned int cmtk::SafeCounter::m_Counter [private]

The actual counter.

Definition at line 79 of file cmtkSafeCounter.h.

Mutex for thread-safe exclusive access to counter.

Definition at line 82 of file cmtkSafeCounter.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines