Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
impala::AtomicInt< T > Class Template Reference

#include <atomic.h>

Collaboration diagram for impala::AtomicInt< T >:

Public Member Functions

 AtomicInt (T initial=0)
 
 operator T () const
 
AtomicIntoperator= (T val)
 
AtomicIntoperator= (const AtomicInt< T > &val)
 
AtomicIntoperator+= (T delta)
 
AtomicIntoperator-= (T delta)
 
AtomicIntoperator|= (T v)
 
AtomicIntoperator&= (T v)
 
AtomicIntoperator++ ()
 These define the preincrement (i.e. –value) operators. More...
 
AtomicIntoperator-- ()
 
AtomicInt< T > operator++ (int)
 This is post increment, which needs to return a new object. More...
 
AtomicInt< T > operator-- (int)
 
Read ()
 Safe read of the value. More...
 
UpdateAndFetch (T delta)
 Increments by delta (i.e. += delta) and returns the new val. More...
 
FetchAndUpdate (T delta)
 Increment by delta and returns the old val. More...
 
void UpdateMax (T value)
 Updates the int to 'value' if value is larger. More...
 
void UpdateMin (T value)
 
bool CompareAndSwap (T old_val, T new_val)
 Returns true if the atomic compare-and-swap was successful. More...
 
CompareAndSwapVal (T old_val, T new_val)
 
Swap (const T &new_val)
 Atomically updates value_ with new_val. Returns the old value_. More...
 

Private Attributes

value_
 

Detailed Description

template<typename T>
class impala::AtomicInt< T >

Wrapper for atomic integers. This should be switched to c++ 11 when we can switch. This class overloads operators to behave like a regular integer type but all operators and functions are thread safe.

Definition at line 46 of file atomic.h.

Constructor & Destructor Documentation

template<typename T>
impala::AtomicInt< T >::AtomicInt ( initial = 0)
inline

Definition at line 48 of file atomic.h.

Member Function Documentation

template<typename T>
T impala::AtomicInt< T >::CompareAndSwapVal ( old_val,
new_val 
)
inline

Returns the content of value_ before the operation. If returnValue == old_val, then the atomic compare-and-swap was successful.

Definition at line 137 of file atomic.h.

Referenced by impala::TEST().

template<typename T>
T impala::AtomicInt< T >::FetchAndUpdate ( delta)
inline

Increment by delta and returns the old val.

Definition at line 110 of file atomic.h.

Referenced by impala::TEST().

template<typename T>
impala::AtomicInt< T >::operator T ( ) const
inline

Definition at line 50 of file atomic.h.

template<typename T>
AtomicInt& impala::AtomicInt< T >::operator&= ( v)
inline

Definition at line 74 of file atomic.h.

template<typename T>
AtomicInt& impala::AtomicInt< T >::operator++ ( )
inline

These define the preincrement (i.e. –value) operators.

Definition at line 80 of file atomic.h.

template<typename T>
AtomicInt<T> impala::AtomicInt< T >::operator++ ( int  )
inline

This is post increment, which needs to return a new object.

Definition at line 90 of file atomic.h.

template<typename T>
AtomicInt& impala::AtomicInt< T >::operator+= ( delta)
inline

Definition at line 61 of file atomic.h.

template<typename T>
AtomicInt& impala::AtomicInt< T >::operator-- ( )
inline

Definition at line 84 of file atomic.h.

template<typename T>
AtomicInt<T> impala::AtomicInt< T >::operator-- ( int  )
inline

Definition at line 94 of file atomic.h.

template<typename T>
AtomicInt& impala::AtomicInt< T >::operator-= ( delta)
inline

Definition at line 65 of file atomic.h.

template<typename T>
AtomicInt& impala::AtomicInt< T >::operator= ( val)
inline

Definition at line 52 of file atomic.h.

template<typename T>
AtomicInt& impala::AtomicInt< T >::operator= ( const AtomicInt< T > &  val)
inline

Definition at line 56 of file atomic.h.

template<typename T>
AtomicInt& impala::AtomicInt< T >::operator|= ( v)
inline

Definition at line 70 of file atomic.h.

template<typename T>
T impala::AtomicInt< T >::Read ( )
inline
template<typename T>
T impala::AtomicInt< T >::Swap ( const T &  new_val)
inline

Atomically updates value_ with new_val. Returns the old value_.

Definition at line 142 of file atomic.h.

Referenced by impala::TEST(), and impala::PeriodicCounterUpdater::~PeriodicCounterUpdater().

template<typename T>
T impala::AtomicInt< T >::UpdateAndFetch ( delta)
inline

Increments by delta (i.e. += delta) and returns the new val.

Definition at line 105 of file atomic.h.

Referenced by impala::RuntimeProfile::HighWaterMarkCounter::Add(), impala::HdfsOperationSet::MarkOneOpDone(), impala::MemTracker::Release(), and impala::TEST().

template<typename T>
void impala::AtomicInt< T >::UpdateMax ( value)
inline
template<typename T>
void impala::AtomicInt< T >::UpdateMin ( value)
inline

Definition at line 122 of file atomic.h.

Referenced by impala::TEST().

Member Data Documentation


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