libMesh
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
libMesh::Threads::atomic< T > Class Template Reference

Defines atomic operations which can only be executed on a single thread at a time. More...

#include <threads_none.h>

Inheritance diagram for libMesh::Threads::atomic< T >:
[legend]

Public Member Functions

 atomic ()
 
 operator T& ()
 
 atomic ()
 
 operator T ()
 
T operator= (T value)
 
atomic< T > & operator= (const atomic< T > &value)
 
T operator+= (T value)
 
T operator-= (T value)
 
T operator++ ()
 
T operator++ (int)
 
T operator-- ()
 
T operator-- (int)
 
 atomic ()
 

Private Attributes

T _val
 
T val
 
spin_mutex smutex
 

Detailed Description

template<typename T>
class libMesh::Threads::atomic< T >

Defines atomic operations which can only be executed on a single thread at a time.

This is used in reference counting, for example, to allow count++/count– to work.

Legacy TBB: inherits tbb::atomic<T>. oneTBB: tbb::atomic was removed; inherits std::atomic<T> instead.

Definition at line 188 of file threads_none.h.

Constructor & Destructor Documentation

◆ atomic() [1/3]

template<typename T >
libMesh::Threads::atomic< T >::atomic ( )
inline

Definition at line 191 of file threads_none.h.

◆ atomic() [2/3]

template<typename T >
libMesh::Threads::atomic< T >::atomic ( )
inline

Definition at line 498 of file threads_pthread.h.

◆ atomic() [3/3]

template<typename T >
libMesh::Threads::atomic< T >::atomic ( )
inline

Definition at line 330 of file threads_tbb.h.

330: std::atomic<T>(0) {}

Member Function Documentation

◆ operator T()

template<typename T >
libMesh::Threads::atomic< T >::operator T ( )
inline

Definition at line 499 of file threads_pthread.h.

499{ return val; }

References libMesh::Threads::atomic< T >::val.

◆ operator T&()

template<typename T >
libMesh::Threads::atomic< T >::operator T& ( )
inline

Definition at line 192 of file threads_none.h.

192{ return _val; }

References libMesh::Threads::atomic< T >::_val.

◆ operator++() [1/2]

template<typename T >
T libMesh::Threads::atomic< T >::operator++ ( )
inline

Definition at line 530 of file threads_pthread.h.

531 {
532 spin_mutex::scoped_lock lock(smutex);
533 val++;
534 return val;
535 }

References libMesh::Threads::atomic< T >::smutex, and libMesh::Threads::atomic< T >::val.

◆ operator++() [2/2]

template<typename T >
T libMesh::Threads::atomic< T >::operator++ ( int  )
inline

Definition at line 537 of file threads_pthread.h.

538 {
539 spin_mutex::scoped_lock lock(smutex);
540 val++;
541 return val;
542 }

References libMesh::Threads::atomic< T >::smutex, and libMesh::Threads::atomic< T >::val.

◆ operator+=()

template<typename T >
T libMesh::Threads::atomic< T >::operator+= ( T  value)
inline

Definition at line 516 of file threads_pthread.h.

517 {
518 spin_mutex::scoped_lock lock(smutex);
519 val += value;
520 return val;
521 }
static const bool value
Definition xdr_io.C:55

References libMesh::Threads::atomic< T >::smutex, libMesh::Threads::atomic< T >::val, and value.

◆ operator--() [1/2]

template<typename T >
T libMesh::Threads::atomic< T >::operator-- ( )
inline

Definition at line 544 of file threads_pthread.h.

545 {
546 spin_mutex::scoped_lock lock(smutex);
547 val--;
548 return val;
549 }

References libMesh::Threads::atomic< T >::smutex, and libMesh::Threads::atomic< T >::val.

◆ operator--() [2/2]

template<typename T >
T libMesh::Threads::atomic< T >::operator-- ( int  )
inline

Definition at line 551 of file threads_pthread.h.

552 {
553 spin_mutex::scoped_lock lock(smutex);
554 val--;
555 return val;
556 }

References libMesh::Threads::atomic< T >::smutex, and libMesh::Threads::atomic< T >::val.

◆ operator-=()

template<typename T >
T libMesh::Threads::atomic< T >::operator-= ( T  value)
inline

Definition at line 523 of file threads_pthread.h.

524 {
525 spin_mutex::scoped_lock lock(smutex);
526 val -= value;
527 return val;
528 }

References libMesh::Threads::atomic< T >::smutex, libMesh::Threads::atomic< T >::val, and value.

◆ operator=() [1/2]

template<typename T >
atomic< T > & libMesh::Threads::atomic< T >::operator= ( const atomic< T > &  value)
inline

Definition at line 508 of file threads_pthread.h.

509 {
510 spin_mutex::scoped_lock lock(smutex);
511 val = value;
512 return *this;
513 }

References libMesh::Threads::atomic< T >::smutex, libMesh::Threads::atomic< T >::val, and value.

◆ operator=() [2/2]

template<typename T >
T libMesh::Threads::atomic< T >::operator= ( T  value)
inline

Definition at line 501 of file threads_pthread.h.

502 {
503 spin_mutex::scoped_lock lock(smutex);
504 val = value;
505 return val;
506 }

References libMesh::Threads::atomic< T >::smutex, libMesh::Threads::atomic< T >::val, and value.

Member Data Documentation

◆ _val

template<typename T >
T libMesh::Threads::atomic< T >::_val
private

Definition at line 194 of file threads_none.h.

Referenced by libMesh::Threads::atomic< T >::operator T&().

◆ smutex

template<typename T >
spin_mutex libMesh::Threads::atomic< T >::smutex
private

◆ val

template<typename T >
T libMesh::Threads::atomic< T >::val
private

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