NCBI C++ ToolKit
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
CAtomicCounter Class Reference

Search Toolkit Book for CAtomicCounter

CAtomicCounter –. More...

#include <corelib/ncbicntr.hpp>

+ Inheritance diagram for CAtomicCounter:

Public Types

typedef TNCBIAtomicValue TValue
 Alias TValue for TNCBIAtomicValue. More...

Public Member Functions

TValue Get (void) const THROWS_NONE
 Get atomic counter value. More...
void Set (TValue new_value) THROWS_NONE
 Set atomic counter value. More...
TValue Add (int delta) THROWS_NONE
 Atomically add value (=delta), and return new counter value. More...

Private Member Functions

typedef NCBI_ATOMIC_TYPE (TValue) TData
 Define NCBI_COUNTER_ADD if one has not been defined. More...

Private Attributes

volatile TData m_Value
 Internal counter value. More...


class CObject

Detailed Description

CAtomicCounter –.

Define a basic atomic counter.

Provide basic counter operations for an atomic counter represented internally by TNCBIAtomicValue.

CAtomicCounter has no constructor and is initialized only when created as static object. In all other cases Set(0) must be called to initialize the counter. CAtomicCounter_WithAutoInit can be used instead of CAtomicCounter if the initialization is required.
TNCBIAtomicValue does not imply any assumptions about the size and the signedness of the value. It is at least as big as int datatype and can be signed on some platforms and unsigned on others.

Definition at line 70 of file ncbicntr.hpp.

The documentation for this class was generated from the following file:
Modified on Thu Sep 28 03:34:52 2023 by rev. 669887