ACE  6.0.7
Public Types | Public Member Functions | Private Attributes
ACE_Atomic_Op_Ex Class Reference

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

#include <Atomic_Op_T.h>

List of all members.

Public Types

typedef ACE_Type_Traits< TYPE >
::parameter_type 
arg_type

Public Member Functions

 ACE_Atomic_Op_Ex (ACE_LOCK &mtx)
 Initialize value_ to 0.
 ACE_Atomic_Op_Ex (ACE_LOCK &mtx, arg_type c)
 Initialize value_ to c.
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.
ACE_Atomic_Op_Ex< ACE_LOCK,
TYPE > & 
operator= (arg_type rhs)
 Atomically assign rhs to value_.
ACE_Atomic_Op_Ex< ACE_LOCK,
TYPE > & 
operator= (ACE_Atomic_Op_Ex< ACE_LOCK, TYPE > const &rhs)
 Atomically assign <rhs> to value_.
TYPE exchange (TYPE newval)
 Exchange value with newval.
TYPE value (void) const
 Explicitly return value_.
void dump (void) const
 Dump the state of an object.
 ACE_Atomic_Op_Ex (ACE_Atomic_Op_Ex< ACE_LOCK, TYPE > const &)
 Manage copying...
ACE_LOCK & mutex (void)
TYPE & value_i (void)

Private Attributes

ACE_LOCK & mutex_
 Type of synchronization mechanism.
TYPE value_
 Current object decorated by the atomic op.

Detailed Description

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.

ACE_Atomic_Op_Ex objects must be constructed with a reference to an existing lock. A single lock can be shared between multiple ACE_Atomic_Op_Ex objects. If you do not require this ability consider using the ACE_Atomic_Op class instead, which may be able to take advantage of platform-specific optimisations to provide atomic operations without requiring a lock.


Member Typedef Documentation

typedef ACE_Type_Traits<TYPE>::parameter_type ACE_Atomic_Op_Ex::arg_type

Constructor & Destructor Documentation

ACE_Atomic_Op_Ex::ACE_Atomic_Op_Ex ( ACE_LOCK &  mtx)

Initialize value_ to 0.

ACE_Atomic_Op_Ex::ACE_Atomic_Op_Ex ( ACE_LOCK &  mtx,
arg_type  c 
)

Initialize value_ to c.

ACE_Atomic_Op_Ex::ACE_Atomic_Op_Ex ( ACE_Atomic_Op_Ex< ACE_LOCK, TYPE > const &  )

Manage copying...


Member Function Documentation

void ACE_Atomic_Op_Ex::dump ( void  ) const

Dump the state of an object.

TYPE ACE_Atomic_Op_Ex::exchange ( TYPE  newval)

Exchange value with newval.

ACE_LOCK& ACE_Atomic_Op_Ex::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_Ex with an ACE_Recursive_Mutex or ACE_Process_Mutex.

Note:
The right name would be lock_, but HP/C++ will choke on that!
bool ACE_Atomic_Op_Ex::operator!= ( arg_type  rhs) const

Atomically compare value_ with rhs.

TYPE ACE_Atomic_Op_Ex::operator++ ( void  )

Atomically pre-increment value_.

TYPE ACE_Atomic_Op_Ex::operator++ ( int  )

Atomically post-increment value_.

TYPE ACE_Atomic_Op_Ex::operator+= ( arg_type  rhs)

Atomically increment value_ by rhs.

TYPE ACE_Atomic_Op_Ex::operator-- ( void  )

Atomically pre-decrement value_.

TYPE ACE_Atomic_Op_Ex::operator-- ( int  )

Atomically post-decrement value_.

TYPE ACE_Atomic_Op_Ex::operator-= ( arg_type  rhs)

Atomically decrement value_ by rhs.

bool ACE_Atomic_Op_Ex::operator< ( arg_type  rhs) const

Atomically check if value_ less than rhs.

bool ACE_Atomic_Op_Ex::operator<= ( arg_type  rhs) const

Atomically check if value_ less than or equal to rhs.

ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>& ACE_Atomic_Op_Ex::operator= ( arg_type  rhs)

Atomically assign rhs to value_.

ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>& ACE_Atomic_Op_Ex::operator= ( ACE_Atomic_Op_Ex< ACE_LOCK, TYPE > const &  rhs)

Atomically assign <rhs> to value_.

bool ACE_Atomic_Op_Ex::operator== ( arg_type  rhs) const

Atomically compare value_ with rhs.

bool ACE_Atomic_Op_Ex::operator> ( arg_type  rhs) const

Atomically check if value_ greater than rhs.

bool ACE_Atomic_Op_Ex::operator>= ( arg_type  rhs) const

Atomically check if value_ greater than or equal to rhs.

TYPE ACE_Atomic_Op_Ex::value ( void  ) const

Explicitly return value_.

TYPE& ACE_Atomic_Op_Ex::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 ;-)


Member Data Documentation

ACE_LOCK& ACE_Atomic_Op_Ex::mutex_ [private]

Type of synchronization mechanism.

TYPE ACE_Atomic_Op_Ex::value_ [private]

Current object decorated by the atomic op.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines