Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

AtomicInt Class Reference

Atomic integer with atomic operations that C can't guarantee us. More...

#include <atomic.h>

Collaboration diagram for AtomicInt:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 AtomicInt (int initial=0)
 Set initial value.

 ~AtomicInt ()
int val () const
 Get current value:.

 operator int () const
void set (int i)
 Set a new value:.

void operator= (int i)
void inc ()
 Increment atomic variable:.

void operator++ ()
void dec ()
 Decrement atomic variable:.

void operator-- ()
bool DecAndTest ()
void add (int i)
 Atomically add intger to atomic variable:.

void operator+= (int i)
void sub (int i)
 Atomically subtract intger to atomic variable:.

void operator-= (int i)
bool SubAndTest (int i)

Private Attributes

FastMutex m
gint v
 No volatile needed.


Detailed Description

Atomic integer with atomic operations that C can't guarantee us.

Useful for resource counting etc...

See also:
File atomic.h for more information.
Author:
Wolfgang Wieser ] wwieser (a) gmx <*> de [

Definition at line 63 of file atomic.h.


Constructor & Destructor Documentation

AtomicInt::AtomicInt int  initial = 0  )  [inline]
 

Set initial value.

Definition at line 79 of file atomic.h.

References USE_PRIVATE__ATOMIC.

AtomicInt::~AtomicInt  )  [inline]
 

Definition at line 85 of file atomic.h.


Member Function Documentation

void AtomicInt::add int  i  )  [inline]
 

Atomically add intger to atomic variable:.

Definition at line 135 of file atomic.h.

References USE_PRIVATE__ATOMIC.

void AtomicInt::dec  )  [inline]
 

Decrement atomic variable:.

Definition at line 116 of file atomic.h.

References USE_PRIVATE__ATOMIC.

bool AtomicInt::DecAndTest  )  [inline]
 

Atomically decrements value by 1 and returns true if the result is 0, or false for all other cases.

Definition at line 127 of file atomic.h.

References USE_PRIVATE__ATOMIC.

Referenced by TLString::_deref(), and TLString::_derefN().

void AtomicInt::inc  )  [inline]
 

Increment atomic variable:.

Definition at line 106 of file atomic.h.

References USE_PRIVATE__ATOMIC.

Referenced by TLString::_aqref(), and TLString::_aqrefN().

AtomicInt::operator int  )  const [inline]
 

Definition at line 94 of file atomic.h.

void AtomicInt::operator++  )  [inline]
 

Definition at line 113 of file atomic.h.

void AtomicInt::operator+= int  i  )  [inline]
 

Definition at line 142 of file atomic.h.

void AtomicInt::operator--  )  [inline]
 

Definition at line 123 of file atomic.h.

void AtomicInt::operator-= int  i  )  [inline]
 

Definition at line 151 of file atomic.h.

void AtomicInt::operator= int  i  )  [inline]
 

Definition at line 103 of file atomic.h.

void AtomicInt::set int  i  )  [inline]
 

Set a new value:.

Definition at line 97 of file atomic.h.

References USE_PRIVATE__ATOMIC.

Referenced by MessageManager::_RecomputeMTMask().

void AtomicInt::sub int  i  )  [inline]
 

Atomically subtract intger to atomic variable:.

Definition at line 145 of file atomic.h.

References USE_PRIVATE__ATOMIC.

bool AtomicInt::SubAndTest int  i  )  [inline]
 

Atomically subtracts i from v and returns true if the result is zero, or false for all other cases.

Definition at line 155 of file atomic.h.

References USE_PRIVATE__ATOMIC.

int AtomicInt::val  )  const [inline]
 

Get current value:.

Definition at line 88 of file atomic.h.

Referenced by TLString::_detachN(), TLString::SData::_DoTightenSize(), TLString::SData::_EnsureSize(), MessageManager::_IsRequestedType(), TLString::SData::DownSizeIfNeeded(), TLString::skip(), TLString::TightenSize(), TLString::trunc(), TLString::vsprintf(), and TLString::zero().


Member Data Documentation

FastMutex AtomicInt::m [private]
 

Definition at line 73 of file atomic.h.

gint AtomicInt::v [private]
 

No volatile needed.

Definition at line 74 of file atomic.h.


The documentation for this class was generated from the following file:
Generated on Sat Feb 19 22:35:21 2005 for Ray by doxygen 1.3.5