ACE_Atomic_Op< ACE_LOCK, TYPE > Class Template Reference

Transparently parameterizes synchronization into basic arithmetic operations. More...

#include <Atomic_Op_T.h>

Collaboration diagram for ACE_Atomic_Op< ACE_LOCK, TYPE >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_Atomic_Op (void)
 Initialize to 0.

 ACE_Atomic_Op (const TYPE &c)
 Initialize to c.

 ACE_Atomic_Op (const ACE_Atomic_Op< ACE_LOCK, TYPE > &c)
 Manage copying...

ACE_Atomic_Op< ACE_LOCK, TYPE > & operator= (const TYPE &rhs)
 Atomically assign rhs to .

ACE_Atomic_Op< ACE_LOCK, TYPE > & operator= (const ACE_Atomic_Op< ACE_LOCK, TYPE > &rhs)
 Atomically assign to .

TYPE operator++ (void)
 Atomically pre-increment .

TYPE operator++ (int)
 Atomically post-increment .

TYPE operator+= (const TYPE &rhs)
 Atomically increment by rhs.

TYPE operator-- (void)
 Atomically pre-decrement .

TYPE operator-- (int)
 Atomically post-decrement .

TYPE operator-= (const TYPE &rhs)
 Atomically decrement by rhs.

bool operator== (const TYPE &rhs) const
 Atomically compare with rhs.

bool operator!= (const TYPE &rhs) const
 Atomically compare with rhs.

bool operator>= (const TYPE &rhs) const
 Atomically check if greater than or equal to rhs.

bool operator> (const TYPE &rhs) const
 Atomically check if greater than rhs.

bool operator<= (const TYPE &rhs) const
 Atomically check if less than or equal to rhs.

bool operator< (const TYPE &rhs) const
 Atomically check if less than rhs.

TYPE value (void) const
 Explicitly return .

void dump (void) const
 Dump the state of an object.

ACE_LOCK & mutex (void)
TYPE & value_i (void)

Private Attributes

ACE_LOCK own_mutex_
 Type of synchronization mechanism.

ACE_Atomic_Op_Ex< ACE_LOCK,
TYPE > 
impl_
 Underlying atomic op implementation.


Detailed Description

template<class ACE_LOCK, class TYPE>
class ACE_Atomic_Op< ACE_LOCK, TYPE >

Transparently parameterizes synchronization into basic arithmetic operations.

This class is described in an article in the July/August 1994 issue of the C++ Report magazine. It implements a templatized version of the Decorator pattern from the GoF book.

Certain platforms may provide a template specialization for ACE_Atomic_Op <ACE_Thread_Mutex, long> that provides optimized atomic integer operations without actually requiring a mutex.

Definition at line 151 of file Atomic_Op_T.h.


Constructor & Destructor Documentation

template<class ACE_LOCK, class TYPE>
ACE_Atomic_Op< ACE_LOCK, TYPE >::ACE_Atomic_Op void   ) 
 

Initialize to 0.

Definition at line 62 of file Atomic_Op_T.cpp.

00063   : impl_ (this->own_mutex_)
00064 {
00065   // ACE_TRACE ("ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op");
00066 }

template<class ACE_LOCK, class TYPE>
ACE_Atomic_Op< ACE_LOCK, TYPE >::ACE_Atomic_Op const TYPE &  c  ) 
 

Initialize to c.

Definition at line 69 of file Atomic_Op_T.cpp.

00070   : impl_ (this->own_mutex_, c)
00071 {
00072   // ACE_TRACE ("ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op");
00073 }

template<class ACE_LOCK, class TYPE>
ACE_INLINE ACE_Atomic_Op< ACE_LOCK, TYPE >::ACE_Atomic_Op const ACE_Atomic_Op< ACE_LOCK, TYPE > &  c  ) 
 

Manage copying...

Definition at line 163 of file Atomic_Op_T.inl.

00164   : impl_ (this->own_mutex_, rhs.value ())
00165 {
00166 // ACE_TRACE ("ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op");
00167 }


Member Function Documentation

template<class ACE_LOCK, class TYPE>
ACE_INLINE void ACE_Atomic_Op< ACE_LOCK, TYPE >::dump void   )  const
 

Dump the state of an object.

Definition at line 263 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00264 {
00265 #if defined (ACE_HAS_DUMP)
00266   this->impl_.dump ();
00267 #endif /* ACE_HAS_DUMP */
00268   return;
00269 }

template<class ACE_LOCK, class TYPE>
ACE_INLINE ACE_LOCK & ACE_Atomic_Op< ACE_LOCK, TYPE >::mutex void   ) 
 

Returns a reference to the underlying . This makes it possible to acquire the lock explicitly, which can be useful in some cases if you instantiate the ACE_Atomic_Op with an ACE_Recursive_Mutex or ACE_Process_Mutex.

Deprecated:
This member function is deprecated and so may go away in the future. If you need access to the underlying mutex, consider using the ACE_Atomic_Op_Ex template instead.

Definition at line 272 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::own_mutex_.

00273 {
00274   return this->own_mutex_;
00275 }

template<class ACE_LOCK, class TYPE>
ACE_INLINE bool ACE_Atomic_Op< ACE_LOCK, TYPE >::operator!= const TYPE &  rhs  )  const
 

Atomically compare with rhs.

Definition at line 227 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00228 {
00229   return this->impl_ != rhs;
00230 }

template<class ACE_LOCK, class TYPE>
ACE_INLINE TYPE ACE_Atomic_Op< ACE_LOCK, TYPE >::operator++ int   ) 
 

Atomically post-increment .

Definition at line 191 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00192 {
00193   return this->impl_++;
00194 }

template<class ACE_LOCK, class TYPE>
ACE_INLINE TYPE ACE_Atomic_Op< ACE_LOCK, TYPE >::operator++ void   ) 
 

Atomically pre-increment .

Definition at line 185 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00186 {
00187   return ++this->impl_;
00188 }

template<class ACE_LOCK, class TYPE>
ACE_INLINE TYPE ACE_Atomic_Op< ACE_LOCK, TYPE >::operator+= const TYPE &  rhs  ) 
 

Atomically increment by rhs.

Definition at line 197 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00198 {
00199   return this->impl_ += rhs;
00200 }

template<class ACE_LOCK, class TYPE>
ACE_INLINE TYPE ACE_Atomic_Op< ACE_LOCK, TYPE >::operator-- int   ) 
 

Atomically post-decrement .

Definition at line 209 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00210 {
00211   return this->impl_--;
00212 }

template<class ACE_LOCK, class TYPE>
ACE_INLINE TYPE ACE_Atomic_Op< ACE_LOCK, TYPE >::operator-- void   ) 
 

Atomically pre-decrement .

Definition at line 203 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00204 {
00205   return --this->impl_;
00206 }

template<class ACE_LOCK, class TYPE>
ACE_INLINE TYPE ACE_Atomic_Op< ACE_LOCK, TYPE >::operator-= const TYPE &  rhs  ) 
 

Atomically decrement by rhs.

Definition at line 215 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00216 {
00217   return this->impl_ -= rhs;
00218 }

template<class ACE_LOCK, class TYPE>
ACE_INLINE bool ACE_Atomic_Op< ACE_LOCK, TYPE >::operator< const TYPE &  rhs  )  const
 

Atomically check if less than rhs.

Definition at line 251 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00252 {
00253   return this->impl_ < rhs;
00254 }

template<class ACE_LOCK, class TYPE>
ACE_INLINE bool ACE_Atomic_Op< ACE_LOCK, TYPE >::operator<= const TYPE &  rhs  )  const
 

Atomically check if less than or equal to rhs.

Definition at line 245 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00246 {
00247   return this->impl_ <= rhs;
00248 }

template<class ACE_LOCK, class TYPE>
ACE_INLINE ACE_Atomic_Op< ACE_LOCK, TYPE > & ACE_Atomic_Op< ACE_LOCK, TYPE >::operator= const ACE_Atomic_Op< ACE_LOCK, TYPE > &  rhs  ) 
 

Atomically assign to .

Definition at line 178 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00179 {
00180   this->impl_ = rhs.impl_;
00181   return *this;
00182 }

template<class ACE_LOCK, class TYPE>
ACE_INLINE ACE_Atomic_Op< ACE_LOCK, TYPE > & ACE_Atomic_Op< ACE_LOCK, TYPE >::operator= const TYPE &  rhs  ) 
 

Atomically assign rhs to .

Definition at line 171 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00172 {
00173   this->impl_ = i;
00174   return *this;
00175 }

template<class ACE_LOCK, class TYPE>
ACE_INLINE bool ACE_Atomic_Op< ACE_LOCK, TYPE >::operator== const TYPE &  rhs  )  const
 

Atomically compare with rhs.

Definition at line 221 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00222 {
00223   return this->impl_ == rhs;
00224 }

template<class ACE_LOCK, class TYPE>
ACE_INLINE bool ACE_Atomic_Op< ACE_LOCK, TYPE >::operator> const TYPE &  rhs  )  const
 

Atomically check if greater than rhs.

Definition at line 239 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00240 {
00241   return this->impl_ > rhs;
00242 }

template<class ACE_LOCK, class TYPE>
ACE_INLINE bool ACE_Atomic_Op< ACE_LOCK, TYPE >::operator>= const TYPE &  rhs  )  const
 

Atomically check if greater than or equal to rhs.

Definition at line 233 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00234 {
00235   return this->impl_ >= rhs;
00236 }

template<class ACE_LOCK, class TYPE>
ACE_INLINE TYPE ACE_Atomic_Op< ACE_LOCK, TYPE >::value void   )  const
 

Explicitly return .

Definition at line 257 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00258 {
00259   return this->impl_.value ();
00260 }

template<class ACE_LOCK, class TYPE>
ACE_INLINE TYPE & ACE_Atomic_Op< ACE_LOCK, TYPE >::value_i void   ) 
 

Explicitly return (by reference). This gives the user full, unrestricted access to the underlying value. This method will usually be used in conjunction with explicit access to the lock. Use with care ;-)

Definition at line 278 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00279 {
00280   return this->impl_.value_i ();
00281 }


Member Data Documentation

template<class ACE_LOCK, class TYPE>
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE> ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_ [private]
 

Underlying atomic op implementation.

Definition at line 236 of file Atomic_Op_T.h.

Referenced by ACE_Atomic_Op< ACE_LOCK, TYPE >::dump(), ACE_Atomic_Op< ACE_LOCK, TYPE >::operator!=(), ACE_Atomic_Op< ACE_LOCK, TYPE >::operator++(), ACE_Atomic_Op< ACE_LOCK, TYPE >::operator+=(), ACE_Atomic_Op< ACE_LOCK, TYPE >::operator--(), ACE_Atomic_Op< ACE_LOCK, TYPE >::operator-=(), ACE_Atomic_Op< ACE_LOCK, TYPE >::operator<(), ACE_Atomic_Op< ACE_LOCK, TYPE >::operator<=(), ACE_Atomic_Op< ACE_LOCK, TYPE >::operator=(), ACE_Atomic_Op< ACE_LOCK, TYPE >::operator==(), ACE_Atomic_Op< ACE_LOCK, TYPE >::operator>(), ACE_Atomic_Op< ACE_LOCK, TYPE >::operator>=(), ACE_Atomic_Op< ACE_LOCK, TYPE >::value(), and ACE_Atomic_Op< ACE_LOCK, TYPE >::value_i().

template<class ACE_LOCK, class TYPE>
ACE_LOCK ACE_Atomic_Op< ACE_LOCK, TYPE >::own_mutex_ [private]
 

Type of synchronization mechanism.

Definition at line 233 of file Atomic_Op_T.h.

Referenced by ACE_Atomic_Op< ACE_LOCK, TYPE >::mutex().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:20:10 2006 for ACE by doxygen 1.3.6