Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 ( )
default

default initialization (same as std::atomic)

constexpr AtomicMovable ( T  desired)
inline

value initialization (same as std::atomic)

Definition at line 41 of file atomic_movable.hpp.

AtomicMovable ( const AtomicMovable< T > &  rhs)
inlinenoexcept

copy-construction (same as std::atomic)

Definition at line 45 of file atomic_movable.hpp.

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

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

copy-assignment (same as std::atomic)

Definition at line 55 of file atomic_movable.hpp.

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.

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: