Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

PAtomicInteger Class Reference

#include <critsec.h>

List of all members.

Public Member Functions

 PAtomicInteger (long v=0)
BOOL IsZero () const
long operator++ ()
long operator-- ()
 operator long () const
void SetValue (long v)

Protected Attributes

long value


Detailed Description

This class implements an integer that can be atomically incremented and decremented in a thread-safe manner. On Windows, the integer is of type long and this class is implemented using InterlockedIncrement and InterlockedDecrement integer is of type long. On Unix systems with GNU std++ support for EXCHANGE_AND_ADD, the integer is of type _Atomic_word (normally int) On all other systems, this class is implemented using PCriticalSection and the integer is of type int.


Constructor & Destructor Documentation

PAtomicInteger::PAtomicInteger long  v = 0  )  [inline]
 

Create a PAtomicInteger with the specified initial value


Member Function Documentation

BOOL PAtomicInteger::IsZero  )  const [inline]
 

Test if an atomic integer has a zero value. Note that this is a non-atomic test - use the return value of the operator++() or operator--() tests to perform atomic operations

Returns:
TRUE if the integer has a value of zero

PAtomicInteger::operator long  )  const [inline]
 

Returns:
Returns the value of the integer

long PAtomicInteger::operator++  )  [inline]
 

atomically increment the integer value

Returns:
Returns the value of the integer after the increment

long PAtomicInteger::operator--  )  [inline]
 

atomically decrement the integer value

Returns:
Returns the value of the integer after the decrement

void PAtomicInteger::SetValue long  v  )  [inline]
 

Set the value of the integer


Member Data Documentation

long PAtomicInteger::value [protected]
 


The documentation for this class was generated from the following file:
Generated on Mon Feb 21 20:43:11 2005 for PWLib by  doxygen 1.4.1