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 Types

typedef ACE_Type_Traits< TYPE
>::parameter_type 
arg_type

Public Member Functions

 ACE_Atomic_Op (void)
 Initialize value_ to 0.
 ACE_Atomic_Op (arg_type c)
 Initialize value_ to c.
 ACE_Atomic_Op (ACE_Atomic_Op< ACE_LOCK, TYPE > const &c)
 Manage copying...
ACE_Atomic_Op< ACE_LOCK, TYPE > & operator= (arg_type rhs)
 Atomically assign rhs to value_.
ACE_Atomic_Op< ACE_LOCK, TYPE > & operator= (ACE_Atomic_Op< ACE_LOCK, TYPE > const &rhs)
 Atomically assign <rhs> to value_.
TYPE operator++ (void)
 Atomically pre-increment value_.
TYPE operator++ (int)
 Atomically post-increment value_.
TYPE operator+= (arg_type rhs)
 Atomically increment value_ by rhs.
TYPE operator-- (void)
 Atomically pre-decrement value_.
TYPE operator-- (int)
 Atomically post-decrement value_.
TYPE operator-= (arg_type rhs)
 Atomically decrement value_ by rhs.
bool operator== (arg_type rhs) const
 Atomically compare value_ with rhs.
bool operator!= (arg_type rhs) const
 Atomically compare value_ with rhs.
bool operator>= (arg_type rhs) const
 Atomically check if value_ greater than or equal to rhs.
bool operator> (arg_type rhs) const
 Atomically check if value_ greater than rhs.
bool operator<= (arg_type rhs) const
 Atomically check if value_ less than or equal to rhs.
bool operator< (arg_type rhs) const
 Atomically check if value_ less than rhs.
TYPE value (void) const
 Explicitly return value_.
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, typename 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 262 of file Atomic_Op_T.h.


Member Typedef Documentation

template<class ACE_LOCK, typename TYPE>
typedef ACE_Type_Traits<TYPE>::parameter_type ACE_Atomic_Op< ACE_LOCK, TYPE >::arg_type

Definition at line 266 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 value_ to 0.

Definition at line 66 of file Atomic_Op_T.cpp.

00067   : impl_ (this->own_mutex_)
00068 {
00069   // ACE_TRACE ("ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op");
00070 }

template<class ACE_LOCK, typename TYPE>
ACE_Atomic_Op< ACE_LOCK, TYPE >::ACE_Atomic_Op ( arg_type  c  ) 

Initialize value_ to c.

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

Manage copying...

Definition at line 191 of file Atomic_Op_T.inl.

00193   : impl_ (own_mutex_, rhs.value ())
00194 {
00195   // ACE_TRACE ("ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op");
00196 }


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 318 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00319 {
00320 #if defined (ACE_HAS_DUMP)
00321   this->impl_.dump ();
00322 #endif /* ACE_HAS_DUMP */
00323   return;
00324 }

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

Returns a reference to the underlying <ACE_LOCK>. 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 328 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::own_mutex_.

00329 {
00330   return this->own_mutex_;
00331 }

template<class ACE_LOCK, typename TYPE>
bool ACE_Atomic_Op< ACE_LOCK, TYPE >::operator!= ( arg_type  rhs  )  const

Atomically compare value_ with rhs.

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

Atomically post-increment value_.

Definition at line 226 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00227 {
00228   return this->impl_++;
00229 }

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

Atomically pre-increment value_.

Definition at line 219 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00220 {
00221   return ++this->impl_;
00222 }

template<class ACE_LOCK, typename TYPE>
TYPE ACE_Atomic_Op< ACE_LOCK, TYPE >::operator+= ( arg_type  rhs  ) 

Atomically increment value_ by rhs.

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

Atomically post-decrement value_.

Definition at line 248 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00249 {
00250   return this->impl_--;
00251 }

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

Atomically pre-decrement value_.

Definition at line 241 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00242 {
00243   return --this->impl_;
00244 }

template<class ACE_LOCK, typename TYPE>
TYPE ACE_Atomic_Op< ACE_LOCK, TYPE >::operator-= ( arg_type  rhs  ) 

Atomically decrement value_ by rhs.

template<class ACE_LOCK, typename TYPE>
bool ACE_Atomic_Op< ACE_LOCK, TYPE >::operator< ( arg_type  rhs  )  const

Atomically check if value_ less than rhs.

template<class ACE_LOCK, typename TYPE>
bool ACE_Atomic_Op< ACE_LOCK, TYPE >::operator<= ( arg_type  rhs  )  const

Atomically check if value_ less than or equal to rhs.

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

Atomically assign <rhs> to value_.

Definition at line 210 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00212 {
00213   this->impl_ = rhs.impl_;
00214   return *this;
00215 }

template<class ACE_LOCK, typename TYPE>
ACE_Atomic_Op<ACE_LOCK, TYPE>& ACE_Atomic_Op< ACE_LOCK, TYPE >::operator= ( arg_type  rhs  ) 

Atomically assign rhs to value_.

template<class ACE_LOCK, typename TYPE>
bool ACE_Atomic_Op< ACE_LOCK, TYPE >::operator== ( arg_type  rhs  )  const

Atomically compare value_ with rhs.

template<class ACE_LOCK, typename TYPE>
bool ACE_Atomic_Op< ACE_LOCK, TYPE >::operator> ( arg_type  rhs  )  const

Atomically check if value_ greater than rhs.

template<class ACE_LOCK, typename TYPE>
bool ACE_Atomic_Op< ACE_LOCK, TYPE >::operator>= ( arg_type  rhs  )  const

Atomically check if value_ greater than or equal to rhs.

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

Explicitly return value_.

Definition at line 311 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

Referenced by ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::count(), and ACE_Refcountable_T< ACE_LOCK >::refcount().

00312 {
00313   return this->impl_.value ();
00314 }

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

Explicitly return value_ (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 335 of file Atomic_Op_T.inl.

References ACE_Atomic_Op< ACE_LOCK, TYPE >::impl_.

00336 {
00337   return this->impl_.value_i ();
00338 }


Member Data Documentation

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

Underlying atomic op implementation.

Definition at line 351 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 >::value(), and ACE_Atomic_Op< ACE_LOCK, TYPE >::value_i().

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

Type of synchronization mechanism.

Definition at line 348 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 Tue Feb 2 17:34:55 2010 for ACE by  doxygen 1.4.7