BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bsls::AtomicPointer< TYPE > Class Template Reference

#include <bsls_atomic.h>

Detailed Description

template<class TYPE>
class bsls::AtomicPointer< TYPE >

This class implements an atomic pointer to a parameterized TYPE, which supports common pointer 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

Public Member Functions

 AtomicPointer ()
 
 AtomicPointer (TYPE *value)
 
 ~AtomicPointer ()=default
 
AtomicPointer< TYPE > & operator= (TYPE *value)
 
void store (TYPE *value)
 
void storeRelaxed (TYPE *value)
 
void storeRelease (TYPE *value)
 
TYPE * swap (TYPE *swapValue)
 
TYPE * swapAcqRel (TYPE *swapValue)
 
TYPE * testAndSwap (const TYPE *compareValue, TYPE *swapValue)
 
TYPE * testAndSwapAcqRel (const TYPE *compareValue, TYPE *swapValue)
 
TYPE & operator* () const
 
TYPE * operator-> () const
 
 operator TYPE * () const
 
TYPE * load () const
 
TYPE * loadRelaxed () const
 
TYPE * loadAcquire () const
 

Constructor & Destructor Documentation

◆ AtomicPointer() [1/2]

template<class TYPE >
bsls::AtomicPointer< TYPE >::AtomicPointer ( )
inline

Create an atomic pointer object having the default value NULL.

◆ AtomicPointer() [2/2]

template<class TYPE >
bsls::AtomicPointer< TYPE >::AtomicPointer ( TYPE *  value)
inline

Create an atomic pointer object having the specified value.

◆ ~AtomicPointer()

template<class TYPE >
bsls::AtomicPointer< TYPE >::~AtomicPointer ( )
default

Member Function Documentation

◆ load()

template<class TYPE >
TYPE * bsls::AtomicPointer< TYPE >::load ( ) const
inline

Return the current value of this object.

◆ loadAcquire()

template<class TYPE >
TYPE * bsls::AtomicPointer< TYPE >::loadAcquire ( ) const
inline

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

◆ loadRelaxed()

template<class TYPE >
TYPE * bsls::AtomicPointer< TYPE >::loadRelaxed ( ) const
inline

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

◆ operator TYPE *()

template<class TYPE >
bsls::AtomicPointer< TYPE >::operator TYPE * ( ) const
inline

Return the current value of this object.

◆ operator*()

template<class TYPE >
TYPE & bsls::AtomicPointer< TYPE >::operator* ( ) const
inline

Return a reference to the value currently pointed to by this object.

Precondition
The behavior is undefined if this pointer has a value of 0.

◆ operator->()

template<class TYPE >
TYPE * bsls::AtomicPointer< TYPE >::operator-> ( ) const
inline

Return the current value of this object.

◆ operator=()

template<class TYPE >
AtomicPointer< TYPE > & bsls::AtomicPointer< TYPE >::operator= ( TYPE *  value)
inline

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

◆ store()

template<class TYPE >
void bsls::AtomicPointer< TYPE >::store ( TYPE *  value)
inline

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

◆ storeRelaxed()

template<class TYPE >
void bsls::AtomicPointer< TYPE >::storeRelaxed ( TYPE *  value)
inline

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

◆ storeRelease()

template<class TYPE >
void bsls::AtomicPointer< TYPE >::storeRelease ( TYPE *  value)
inline

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

◆ swap()

template<class TYPE >
TYPE * bsls::AtomicPointer< TYPE >::swap ( TYPE *  swapValue)
inline

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

◆ swapAcqRel()

template<class TYPE >
TYPE * bsls::AtomicPointer< TYPE >::swapAcqRel ( TYPE *  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()

template<class TYPE >
TYPE * bsls::AtomicPointer< TYPE >::testAndSwap ( const TYPE *  compareValue,
TYPE *  swapValue 
)
inline

Compare the value of this object to the specified compareValue. If they are equal, set the value of this atomic pointer to the specified swapValue, otherwise leave this value unchanged. Return the previous value of this atomic pointer, whether or not the swap occurred.

Note
Note that the entire test-and-swap operation is performed atomically.

◆ testAndSwapAcqRel()

template<class TYPE >
TYPE * bsls::AtomicPointer< TYPE >::testAndSwapAcqRel ( const TYPE *  compareValue,
TYPE *  swapValue 
)
inline

Compare the value of this object to the specified compareValue. If they are equal, set the value of this atomic pointer to the specified swapValue, otherwise leave this value unchanged. Return the previous value of this atomic pointer, whether or not the swap occurred.

Note
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: