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 ()
 
operator= (T value)
 
atomic< T > & operator= (const atomic< T > &value)
 
operator+= (T value)
 
operator-= (T value)
 
operator++ ()
 
operator++ (int)
 
operator-- ()
 
operator-- (int)
 
 atomic ()
 

Private Attributes

_val
 
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 485 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 486 of file threads_pthread.h.

486{ 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 517 of file threads_pthread.h.

518 {
519 spin_mutex::scoped_lock lock(smutex);
520 val++;
521 return val;
522 }

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 524 of file threads_pthread.h.

525 {
526 spin_mutex::scoped_lock lock(smutex);
527 val++;
528 return val;
529 }

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

◆ operator+=()

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

Definition at line 503 of file threads_pthread.h.

504 {
505 spin_mutex::scoped_lock lock(smutex);
506 val += value;
507 return val;
508 }
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 531 of file threads_pthread.h.

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

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 538 of file threads_pthread.h.

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

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

◆ operator-=()

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

Definition at line 510 of file threads_pthread.h.

511 {
512 spin_mutex::scoped_lock lock(smutex);
513 val -= value;
514 return val;
515 }

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 495 of file threads_pthread.h.

496 {
497 spin_mutex::scoped_lock lock(smutex);
498 val = value;
499 return *this;
500 }

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= ( value)
inline

Definition at line 488 of file threads_pthread.h.

489 {
490 spin_mutex::scoped_lock lock(smutex);
491 val = value;
492 return val;
493 }

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: