DASH  0.3.0
dash::Atomic< T > Class Template Reference

Type wrapper to mark any trivial type atomic. More...

#include <Atomic.h>

Public Types

typedef T value_type
 

Public Member Functions

constexpr Atomic (const Atomic< T > &other)=default
 
constexpr Atomic (Atomic< T > &&other)=default
 
self_toperator= (const self_t &other)=default
 
self_toperator= (self_t &&other)=default
 
constexpr Atomic (T value)
 Initializes the underlying value with desired. More...
 
operator= (T value)=delete
 Disabled assignment as this violates the atomic semantics. More...
 
 operator T ()=delete
 As Atomic is implemented as phantom type, the value has to be queried using the dash::GlobRef. More...
 
constexpr bool operator== (const self_t &other) const
 
constexpr bool operator!= (const self_t &other) const
 

Friends

template<typename T_ >
std::ostream & operator<< (std::ostream &os, const Atomic< T_ > &at)
 

Detailed Description

template<typename T>
class dash::Atomic< T >

Type wrapper to mark any trivial type atomic.

If one unit writes to an atomic object while another unit reads from it, the behavior is well-defined. The DASH version follows as closely as possible the interface of std::atomic However as data has to be transferred between units using DART, the atomicity guarantees are set by the DART implementation.

Note
Atomic objects have to be placed in a DASH container, and can only be accessed using GlobRef<dash::Atomic<T>> . Local accesses to atomic elements are not allowed.
array.local[10].load() // not allowed
dash::atomic::load(array.local[10]) // not allowed
dash::atomic::load(array.lbegin()) // not allowed
// supported as Atomic<value_t>(value_t T) is available
dash::fill(array.begin(), array.end(), 0);
if(dash::myid() == 0){
array[10].store(5);
}
array[10].add(1);
// postcondition:
// array[10] == dash::size() + 5

Definition at line 15 of file GlobAtomicAsyncRef.h.

Constructor & Destructor Documentation

◆ Atomic()

template<typename T >
constexpr dash::Atomic< T >::Atomic ( value)
inline

Initializes the underlying value with desired.

The initialization is not atomic

Definition at line 73 of file Atomic.h.

References dash::typestr().

74  : _value(value) { }

Member Function Documentation

◆ operator T()

template<typename T >
dash::Atomic< T >::operator T ( )
delete

As Atomic is implemented as phantom type, the value has to be queried using the dash::GlobRef.

◆ operator=()

template<typename T >
T dash::Atomic< T >::operator= ( value)
delete

Disabled assignment as this violates the atomic semantics.

Todo:
Assignment semantics are not well-defined:
  • Constructor Atomic(T) is default-defined
  • Assignment Atomic=(T) is deleted

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