Equalizer 1.0

co::base::Atomic< T > Class Template Reference

An variable with atomic operations. More...

#include <atomic.h>

Collaboration diagram for co::base::Atomic< T >:

List of all members.

Public Member Functions

 Atomic (const T v=0)
 Construct a new atomic variable with an initial value.
 Atomic (const Atomic< T > &v)
 Construct a copy of an atomic variable.
 operator T (void) const
void operator= (const T v)
 Assign a new value.
void operator= (const Atomic< T > &v)
 Assign a new value.
operator+= (T v)
 Atomically add a value and return the new value.
operator-= (T v)
 Atomically substract a value and return the new value.
operator++ (void)
 Atomically increment by one and return the new value.
operator-- (void)
 Atomically decrement by one and return the new value.
operator++ (int)
 Atomically increment by one and return the old value.
operator-- (int)
 Atomically decrement by one and return the old value.

Detailed Description

template<typename T>
class co::base::Atomic< T >

An variable with atomic operations.

Atomic variables can be modified safely from multiple threads concurrently. They are useful to implement lock-free algorithms.

For implementation reasons, only signed atomic variables are supported, of which only int32_t is implemented right now.

Definition at line 39 of file atomic.h.


Constructor & Destructor Documentation

template<typename T>
co::base::Atomic< T >::Atomic ( const T  v = 0) [inline, explicit]

Construct a new atomic variable with an initial value.

Version:
1.0

Definition at line 43 of file atomic.h.

template<typename T>
co::base::Atomic< T >::Atomic ( const Atomic< T > &  v) [inline, explicit]

Construct a copy of an atomic variable.

Not thread-safe!

Version:
1.0

Definition at line 48 of file atomic.h.


Member Function Documentation

template<typename T>
co::base::Atomic< T >::operator T ( void  ) const [inline]
Returns:
the current value
Version:
1.0

Definition at line 53 of file atomic.h.

template<typename T>
T co::base::Atomic< T >::operator++ ( int  ) [inline]

Atomically increment by one and return the old value.

Version:
1.0

Definition at line 97 of file atomic.h.

template<typename T>
T co::base::Atomic< T >::operator++ ( void  ) [inline]

Atomically increment by one and return the new value.

Version:
1.0

Definition at line 85 of file atomic.h.

template<typename T>
T co::base::Atomic< T >::operator+= ( v) [inline]

Atomically add a value and return the new value.

Version:
1.0

Definition at line 73 of file atomic.h.

template<typename T>
T co::base::Atomic< T >::operator-- ( int  ) [inline]

Atomically decrement by one and return the old value.

Version:
1.0

Definition at line 103 of file atomic.h.

template<typename T>
T co::base::Atomic< T >::operator-- ( void  ) [inline]

Atomically decrement by one and return the new value.

Version:
1.0

Definition at line 91 of file atomic.h.

template<typename T>
T co::base::Atomic< T >::operator-= ( v) [inline]

Atomically substract a value and return the new value.

Version:
1.0

Definition at line 79 of file atomic.h.

template<typename T>
void co::base::Atomic< T >::operator= ( const Atomic< T > &  v) [inline]

Assign a new value.

Not thread-safe!

Version:
1.0

Definition at line 66 of file atomic.h.

template<typename T>
void co::base::Atomic< T >::operator= ( const T  v) [inline]

Assign a new value.

Version:
1.0

Definition at line 59 of file atomic.h.


The documentation for this class was generated from the following file:
Generated on Sun May 8 2011 19:11:08 for Equalizer 1.0 by  doxygen 1.7.3