#include <Atomic_Op_T.h>
Collaboration diagram for ACE_Atomic_Op_Ex< ACE_LOCK, TYPE >:
Public Member Functions | |
ACE_Atomic_Op_Ex (ACE_LOCK &mtx) | |
Initialize to 0. | |
ACE_Atomic_Op_Ex (ACE_LOCK &mtx, const TYPE &c) | |
Initialize to c. | |
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. | |
ACE_Atomic_Op_Ex< ACE_LOCK, TYPE > & | operator= (const TYPE &rhs) |
Atomically assign rhs to . | |
ACE_Atomic_Op_Ex< ACE_LOCK, TYPE > & | operator= (const ACE_Atomic_Op_Ex< ACE_LOCK, TYPE > &rhs) |
Atomically assign to . | |
TYPE | value (void) const |
Explicitly return . | |
void | dump (void) const |
Dump the state of an object. | |
ACE_Atomic_Op_Ex (const ACE_Atomic_Op_Ex< ACE_LOCK, TYPE > &) | |
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. |
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.
Definition at line 44 of file Atomic_Op_T.h.
|
Initialize to 0.
Definition at line 43 of file Atomic_Op_T.cpp.
|
|
Initialize to c.
Definition at line 52 of file Atomic_Op_T.cpp.
|
|
Manage copying...
Definition at line 46 of file Atomic_Op_T.inl.
|
|
Dump the state of an object.
Definition at line 31 of file Atomic_Op_T.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, LM_DEBUG, and ACE_Atomic_Op_Ex< ACE_LOCK, TYPE >::mutex_.
|
|
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 with an ACE_Recursive_Mutex or ACE_Process_Mutex.
Definition at line 24 of file Atomic_Op_T.cpp. References ACE_Atomic_Op_Ex< ACE_LOCK, TYPE >::mutex_.
00025 { 00026 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::mutex"); 00027 return this->mutex_; 00028 } |
|
Atomically compare with rhs.
Definition at line 78 of file Atomic_Op_T.inl.
00079 { 00080 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator!="); 00081 return !(*this == rhs); 00082 } |
|
Atomically post-increment .
Definition at line 54 of file Atomic_Op_T.inl. References ACE_GUARD_RETURN, and ACE_Atomic_Op_Ex< ACE_LOCK, TYPE >::value_.
00055 { 00056 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator++"); 00057 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); 00058 return this->value_++; 00059 } |
|
Atomically pre-increment .
Definition at line 14 of file Atomic_Op_T.inl. References ACE_GUARD_RETURN, and ACE_Atomic_Op_Ex< ACE_LOCK, TYPE >::value_.
00015 { 00016 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator++"); 00017 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); 00018 return ++this->value_; 00019 } |
|
Atomically increment by rhs.
Definition at line 22 of file Atomic_Op_T.inl. References ACE_GUARD_RETURN, and ACE_Atomic_Op_Ex< ACE_LOCK, TYPE >::value_.
00023 { 00024 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator+="); 00025 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); 00026 return this->value_ += rhs; 00027 } |
|
Atomically post-decrement .
Definition at line 62 of file Atomic_Op_T.inl. References ACE_GUARD_RETURN, and ACE_Atomic_Op_Ex< ACE_LOCK, TYPE >::value_.
00063 { 00064 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator--"); 00065 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); 00066 return this->value_--; 00067 } |
|
Atomically pre-decrement .
Definition at line 30 of file Atomic_Op_T.inl. References ACE_GUARD_RETURN, and ACE_Atomic_Op_Ex< ACE_LOCK, TYPE >::value_.
00031 { 00032 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator--"); 00033 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); 00034 return --this->value_; 00035 } |
|
Atomically decrement by rhs.
Definition at line 38 of file Atomic_Op_T.inl. References ACE_GUARD_RETURN, and ACE_Atomic_Op_Ex< ACE_LOCK, TYPE >::value_.
00039 { 00040 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator-="); 00041 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); 00042 return this->value_ -= rhs; 00043 } |
|
Atomically check if less than rhs.
Definition at line 109 of file Atomic_Op_T.inl. References ACE_GUARD_RETURN, and ACE_Atomic_Op_Ex< ACE_LOCK, TYPE >::value_.
00110 { 00111 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator<"); 00112 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, (ACE_LOCK &) this->mutex_, false); 00113 return this->value_ < rhs; 00114 } |
|
Atomically check if less than or equal to rhs.
Definition at line 101 of file Atomic_Op_T.inl. References ACE_GUARD_RETURN, and ACE_Atomic_Op_Ex< ACE_LOCK, TYPE >::value_.
00102 { 00103 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator<="); 00104 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, (ACE_LOCK &) this->mutex_, false); 00105 return this->value_ <= rhs; 00106 } |
|
Atomically assign to .
Definition at line 117 of file Atomic_Op_T.inl. References ACE_GUARD_RETURN, ACE_Atomic_Op_Ex< ACE_LOCK, TYPE >::value(), and ACE_Atomic_Op_Ex< ACE_LOCK, TYPE >::value_.
00118 { 00119 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator="); 00120 if (&rhs == this) 00121 return *this; // Avoid deadlock... 00122 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, *this); 00123 // This will call ACE_Atomic_Op_Ex::TYPE(), which will ensure the 00124 // value of <rhs> is acquired atomically. 00125 00126 this->value_ = rhs.value (); 00127 return *this; 00128 } |
|
Atomically assign rhs to .
Definition at line 149 of file Atomic_Op_T.inl. References ACE_GUARD_RETURN, and ACE_Atomic_Op_Ex< ACE_LOCK, TYPE >::value_.
00150 { 00151 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator="); 00152 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, *this); 00153 this->value_ = rhs; 00154 return *this; 00155 } |
|
Atomically compare with rhs.
Definition at line 70 of file Atomic_Op_T.inl. References ACE_GUARD_RETURN, and ACE_Atomic_Op_Ex< ACE_LOCK, TYPE >::value_.
00071 { 00072 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator=="); 00073 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, (ACE_LOCK &) this->mutex_, false); 00074 return this->value_ == rhs; 00075 } |
|
Atomically check if greater than rhs.
Definition at line 93 of file Atomic_Op_T.inl. References ACE_GUARD_RETURN, and ACE_Atomic_Op_Ex< ACE_LOCK, TYPE >::value_.
00094 { 00095 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator>"); 00096 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, (ACE_LOCK &) this->mutex_, false); 00097 return this->value_ > rhs; 00098 } |
|
Atomically check if greater than or equal to rhs.
Definition at line 85 of file Atomic_Op_T.inl. References ACE_GUARD_RETURN, and ACE_Atomic_Op_Ex< ACE_LOCK, TYPE >::value_.
00086 { 00087 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator>="); 00088 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, (ACE_LOCK &) this->mutex_, false); 00089 return this->value_ >= rhs; 00090 } |
|
Explicitly return .
Definition at line 131 of file Atomic_Op_T.inl. References ACE_GUARD_RETURN, and ACE_Atomic_Op_Ex< ACE_LOCK, TYPE >::value_. Referenced by ACE_Atomic_Op_Ex< ACE_LOCK, TYPE >::operator=().
00132 { 00133 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::value"); 00134 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, (ACE_LOCK &) this->mutex_, this->value_); 00135 return this->value_; 00136 } |
|
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 139 of file Atomic_Op_T.inl. References ACE_Atomic_Op_Ex< ACE_LOCK, TYPE >::value_.
00140 { 00141 // Explicitly return <value_> (by reference). This gives the user 00142 // full, unrestricted access to the underlying value. This method 00143 // will usually be used in conjunction with explicit access to the 00144 // lock. Use with care ;-) 00145 return this->value_; 00146 } |
|
Type of synchronization mechanism.
Definition at line 130 of file Atomic_Op_T.h. Referenced by ACE_Atomic_Op_Ex< ACE_LOCK, TYPE >::dump(), and ACE_Atomic_Op_Ex< ACE_LOCK, TYPE >::mutex(). |
|