MADNESS 0.10.1
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
madness::AtomicInt Class Reference

An integer with atomic set, get, read+increment, read+decrement, and decrement+test operations. More...

#include <atomicint.h>

Public Member Functions

bool dec_and_test ()
 Decrements the counter and returns true if the new value is zero,.
 
 operator int () const volatile
 Returns the value of the counter with fence, ensuring subsequent operations are not moved before the load.
 
int operator++ ()
 Increments the counter and returns the incremented value.
 
int operator++ (int)
 Increments the counter and returns the original value.
 
int operator+= (const int inc)
 Add value and return the new value.
 
int operator-- ()
 Decrements the counter and returns the decremented value.
 
int operator-- (int)
 Decrements the counter and returns the original value.
 
int operator-= (const int dec)
 Subtract dec and return the new value.
 
AtomicIntoperator= (const AtomicInt &other)
 Sets the value of the counter, with fences to ensure that operations are not moved to either side of the load+store.
 
int operator= (int other)
 

Private Types

typedef volatile int atomic_int
 Storage type for the atomic integer.
 

Private Member Functions

int exchange_and_add (int i)
 

Private Attributes

atomic_int value
 The atomic integer.
 

Detailed Description

An integer with atomic set, get, read+increment, read+decrement, and decrement+test operations.

Only the default constructor is available and it does \emph not initialize the variable.

Consciously modeled after the TBB API to prepare for switching to it.

Todo:
Should we actually switch to the TBB version?

Member Typedef Documentation

◆ atomic_int

typedef volatile int madness::AtomicInt::atomic_int
private

Storage type for the atomic integer.

Member Function Documentation

◆ dec_and_test()

bool madness::AtomicInt::dec_and_test ( )
inline

Decrements the counter and returns true if the new value is zero,.

Returns
True if the decremented value is 0; false otherwise.

Referenced by madness::Barrier::enter(), and madness::detail::RemoteCounterBase::release().

◆ exchange_and_add()

int madness::AtomicInt::exchange_and_add ( int  i)
inlineprivate
Todo:
Brief description needed.
Todo:
Descriptions needed.
Parameters
[in]iDescription needed.
Returns
Description needed.

References value.

Referenced by operator++(), operator++(), operator+=(), operator--(), operator--(), and operator-=().

◆ operator int()

madness::AtomicInt::operator int ( ) const volatile
inline

Returns the value of the counter with fence, ensuring subsequent operations are not moved before the load.

References value.

◆ operator++() [1/2]

int madness::AtomicInt::operator++ ( )
inline

Increments the counter and returns the incremented value.

Returns
The incremented value.

References exchange_and_add(), and value.

◆ operator++() [2/2]

int madness::AtomicInt::operator++ ( int  )
inline

Increments the counter and returns the original value.

Returns
The original value.

References exchange_and_add(), and value.

◆ operator+=()

int madness::AtomicInt::operator+= ( const int  inc)
inline

Add value and return the new value.

Parameters
[in]incThe value to be added.
Returns
The new value.

References exchange_and_add(), and value.

◆ operator--() [1/2]

int madness::AtomicInt::operator-- ( )
inline

Decrements the counter and returns the decremented value.

Returns
The decremented value.

References exchange_and_add(), and value.

◆ operator--() [2/2]

int madness::AtomicInt::operator-- ( int  )
inline

Decrements the counter and returns the original value.

Returns
The original value.

References exchange_and_add(), and value.

◆ operator-=()

int madness::AtomicInt::operator-= ( const int  dec)
inline

Subtract dec and return the new value.

Parameters
[in]decThe value to be subtracted.
Returns
The new value.

References exchange_and_add(), and value.

◆ operator=() [1/2]

AtomicInt & madness::AtomicInt::operator= ( const AtomicInt other)
inline

Sets the value of the counter, with fences to ensure that operations are not moved to either side of the load+store.

Parameters
[in]otherThe value to set to.
Returns
This AtomicInt.

◆ operator=() [2/2]

int madness::AtomicInt::operator= ( int  other)
inline

Sets the value of the counter, with a fence ensuring that preceding operations are not moved after the store.

Todo:
Descriptions needed.
Parameters
[in]otherDescription needed.
Returns
Description needed.

References value.

Member Data Documentation

◆ value

atomic_int madness::AtomicInt::value
private

The documentation for this class was generated from the following file: