Thrill  0.1
AtomicMovable< T > Class Template Reference

Detailed Description

template<typename T>
class thrill::common::AtomicMovable< T >

This is a derivative of std::atomic which enables easier and less error-prone writing of move-only classes by implementing a move constructor.

std::atomic does not have a move constructor for a good reason: atomicity cannot be guaranteed. The problem is that then all move-only classes containing a std::atomic must implement custom move operations. However, in all our cases we only move objects during initialization. Custom move operations are trivial to write but error-prone to maintain, since they must contain all member variables. Missing variables create very subtle bugs, hence it is better to use this AtomicMovable class.

Definition at line 34 of file atomic_movable.hpp.

+ Inheritance diagram for AtomicMovable< T >:

#include <atomic_movable.hpp>

Public Member Functions

 AtomicMovable ()=default
 default initialization (same as std::atomic) More...
 
constexpr AtomicMovable (T desired)
 value initialization (same as std::atomic) More...
 
 AtomicMovable (const AtomicMovable &rhs) noexcept
 copy-construction (same as std::atomic) More...
 
 AtomicMovable (const AtomicMovable &&rhs) noexcept
 
AtomicMovableoperator= (const AtomicMovable &rhs) noexcept
 copy-assignment (same as std::atomic) More...
 
AtomicMovableoperator= (AtomicMovable &&rhs) noexcept
 move-assignment NOT same as std::atomic: load and move. More...
 
T operator= (T desired) noexcept
 assignment operator (same as std::atomic) More...
 

Constructor & Destructor Documentation

◆ AtomicMovable() [1/4]

AtomicMovable ( )
default

default initialization (same as std::atomic)

◆ AtomicMovable() [2/4]

constexpr AtomicMovable ( T  desired)
inline

value initialization (same as std::atomic)

Definition at line 41 of file atomic_movable.hpp.

◆ AtomicMovable() [3/4]

AtomicMovable ( const AtomicMovable< T > &  rhs)
inlinenoexcept

copy-construction (same as std::atomic)

Definition at line 45 of file atomic_movable.hpp.

◆ AtomicMovable() [4/4]

AtomicMovable ( const AtomicMovable< T > &&  rhs)
inlinenoexcept

move-construction NOT same as std::atomic: load and move. Requires T to have an ctor that takes an instance of T for initialization.

Definition at line 51 of file atomic_movable.hpp.

Member Function Documentation

◆ operator=() [1/3]

AtomicMovable& operator= ( const AtomicMovable< T > &  rhs)
inlinenoexcept

copy-assignment (same as std::atomic)

Definition at line 55 of file atomic_movable.hpp.

◆ operator=() [2/3]

AtomicMovable& operator= ( AtomicMovable< T > &&  rhs)
inlinenoexcept

move-assignment NOT same as std::atomic: load and move.

Definition at line 61 of file atomic_movable.hpp.

◆ operator=() [3/3]

T operator= ( T  desired)
inlinenoexcept

assignment operator (same as std::atomic)

Definition at line 67 of file atomic_movable.hpp.


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