libMesh
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)
 

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.

Definition at line 172 of file threads_none.h.

Constructor & Destructor Documentation

◆ atomic() [1/2]

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

Definition at line 175 of file threads_none.h.

◆ atomic() [2/2]

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

Definition at line 470 of file threads_pthread.h.

Member Function Documentation

◆ operator T()

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

Definition at line 471 of file threads_pthread.h.

471 { return val; }

◆ operator T&()

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

Definition at line 176 of file threads_none.h.

176 { return _val; }

◆ operator++() [1/2]

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

Definition at line 502 of file threads_pthread.h.

503  {
504  spin_mutex::scoped_lock lock(smutex);
505  val++;
506  return val;
507  }

◆ operator++() [2/2]

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

Definition at line 509 of file threads_pthread.h.

510  {
511  spin_mutex::scoped_lock lock(smutex);
512  val++;
513  return val;
514  }

◆ operator+=()

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  }
static const bool value
Definition: xdr_io.C:54

◆ operator--() [1/2]

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

Definition at line 516 of file threads_pthread.h.

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

◆ operator--() [2/2]

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

Definition at line 523 of file threads_pthread.h.

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

◆ operator-=()

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

Definition at line 495 of file threads_pthread.h.

496  {
497  spin_mutex::scoped_lock lock(smutex);
498  val -= value;
499  return val;
500  }
static const bool value
Definition: xdr_io.C:54

◆ operator=() [1/2]

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

Definition at line 473 of file threads_pthread.h.

474  {
475  spin_mutex::scoped_lock lock(smutex);
476  val = value;
477  return val;
478  }
static const bool value
Definition: xdr_io.C:54

◆ operator=() [2/2]

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

Definition at line 480 of file threads_pthread.h.

481  {
482  spin_mutex::scoped_lock lock(smutex);
483  val = value;
484  return *this;
485  }
static const bool value
Definition: xdr_io.C:54

Member Data Documentation

◆ _val

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

◆ 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: