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

Parameters:
v  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

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

PAtomicInteger::operator long (  )  const [inline]

Returns:
Returns the value of the integer

void PAtomicInteger::SetValue ( long  v  )  [inline]

Set the value of the integer

Parameters:
v  value to set


Member Data Documentation

long PAtomicInteger::value [protected]


The documentation for this class was generated from the following file:
Generated on Fri Mar 7 06:25:04 2008 for PTLib by  doxygen 1.5.1