BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsls::AtomicInt Class Reference

#include <bsls_atomic.h>

Public Member Functions

 AtomicInt ()
 Create an atomic integer object having the default value 0.
 
 AtomicInt (int value)
 Create an atomic integer object having the specified value.
 
 ~AtomicInt ()=default
 
AtomicIntoperator= (int value)
 
int operator+= (int value)
 
int operator-= (int value)
 
int operator++ ()
 
int operator++ (int)
 
int operator-- ()
 
int operator-- (int)
 
int add (int value)
 
int addAcqRel (int value)
 
int addRelaxed (int value)
 
void store (int value)
 
void storeRelaxed (int value)
 
void storeRelease (int value)
 
int subtract (int value)
 
int subtractAcqRel (int value)
 
int subtractRelaxed (int value)
 
int swap (int swapValue)
 
int swapAcqRel (int swapValue)
 
int testAndSwap (int compareValue, int swapValue)
 
int testAndSwapAcqRel (int compareValue, int swapValue)
 
 operator int () const
 Return the current value of this object.
 
int load () const
 Return the current value of this object.
 
int loadAcquire () const
 
int loadRelaxed () const
 

Detailed Description

This class implements an atomic integer, which supports common integer operations in a way that is guaranteed to be atomic. Operations on objects of this class provide the sequential consistency memory ordering guarantee unless explicitly qualified with a less strict consistency guarantee suffix (i.e., Acquire, Release, AcqRel or Relaxed).

See bsls_atomic

Constructor & Destructor Documentation

◆ AtomicInt() [1/2]

bsls::AtomicInt::AtomicInt ( )
inline

◆ AtomicInt() [2/2]

bsls::AtomicInt::AtomicInt ( int  value)
inline

◆ ~AtomicInt()

bsls::AtomicInt::~AtomicInt ( )
default

Member Function Documentation

◆ add()

int bsls::AtomicInt::add ( int  value)
inline

Atomically add the specified value to this object and return the resulting value.

◆ addAcqRel()

int bsls::AtomicInt::addAcqRel ( int  value)
inline

Atomically add the specified value to this object and return the resulting value, providing the acquire/release memory ordering guarantee.

◆ addRelaxed()

int bsls::AtomicInt::addRelaxed ( int  value)
inline

Atomically add the specified value to this object and return the resulting value, providing the relaxed memory ordering guarantee.

◆ load()

int bsls::AtomicInt::load ( ) const
inline

◆ loadAcquire()

int bsls::AtomicInt::loadAcquire ( ) const
inline

Return the current value of this object, providing the acquire memory ordering guarantee.

◆ loadRelaxed()

int bsls::AtomicInt::loadRelaxed ( ) const
inline

Return the current value of this object, providing the relaxed memory ordering guarantee.

◆ operator int()

bsls::AtomicInt::operator int ( ) const
inline

◆ operator++() [1/2]

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

Atomically increment the value of this object by 1 and return the resulting value.

◆ operator++() [2/2]

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

Atomically increment the value of this object by 1 and return the value prior to being incremented.

◆ operator+=()

int bsls::AtomicInt::operator+= ( int  value)
inline

Atomically add the specified value to this object, and return the resulting value.

◆ operator--() [1/2]

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

Atomically decrement the value of this object by 1 and return the resulting value.

◆ operator--() [2/2]

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

Atomically decrement the value of this object by 1 and return the value prior to being decremented.

◆ operator-=()

int bsls::AtomicInt::operator-= ( int  value)
inline

Atomically subtract the specified value from this object, and return the resulting value.

◆ operator=()

AtomicInt & bsls::AtomicInt::operator= ( int  value)
inline

Atomically assign the specified value to this object, and return a reference offering modifiable access to this object.

◆ store()

void bsls::AtomicInt::store ( int  value)
inline

Atomically assign the specified value to this object, providing the sequential consistency memory ordering guarantee.

◆ storeRelaxed()

void bsls::AtomicInt::storeRelaxed ( int  value)
inline

Atomically assign the specified value to this object, providing the relaxed memory ordering guarantee.

◆ storeRelease()

void bsls::AtomicInt::storeRelease ( int  value)
inline

Atomically assign the specified value to this object, providing the release memory ordering guarantee.

◆ subtract()

int bsls::AtomicInt::subtract ( int  value)
inline

Atomically subtract the specified value to this object and return the resulting value.

◆ subtractAcqRel()

int bsls::AtomicInt::subtractAcqRel ( int  value)
inline

Atomically subtract the specified value to this object and return the resulting value, providing the acquire/release memory ordering guarantee.

◆ subtractRelaxed()

int bsls::AtomicInt::subtractRelaxed ( int  value)
inline

Atomically subtract the specified value to this object and return the resulting value, providing the relaxed memory ordering guarantee.

◆ swap()

int bsls::AtomicInt::swap ( int  swapValue)
inline

Atomically set the value of this object to the specified swapValue and return its previous value.

◆ swapAcqRel()

int bsls::AtomicInt::swapAcqRel ( int  swapValue)
inline

Atomically set the value of this object to the specified swapValue and return its previous value, providing the acquire/release memory ordering guarantee.

◆ testAndSwap()

int bsls::AtomicInt::testAndSwap ( int  compareValue,
int  swapValue 
)
inline

Compare the value of this object to the specified compareValue. If they are equal, set the value of this atomic integer to the specified swapValue, otherwise leave this value unchanged. Return the previous value of this atomic integer, whether or not the swap occurred. Note that the entire test-and-swap operation is performed atomically.

◆ testAndSwapAcqRel()

int bsls::AtomicInt::testAndSwapAcqRel ( int  compareValue,
int  swapValue 
)
inline

Compare the value of this object to the specified compareValue. If they are equal, set the value of this atomic integer to the specified swapValue, otherwise leave this value unchanged. Return the previous value of this atomic integer, whether or not the swap occurred. Note that the entire test-and-swap operation is performed atomically and it provides the acquire/release memory ordering guarantee.


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