Atomic_Op_T.inl

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Atomic_Op_T.inl,v 4.4 2005/10/28 16:14:51 ossama Exp
00004 
00005 #include "ace/Guard_T.h"
00006 
00007 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00008 
00009 //
00010 // ACE_Atomic_Op_Ex inline functions
00011 //
00012 
00013 template <class ACE_LOCK, class TYPE> ACE_INLINE TYPE
00014 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator++ (void)
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 }
00020 
00021 template <class ACE_LOCK, class TYPE> ACE_INLINE TYPE
00022 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator+= (const TYPE &rhs)
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 }
00028 
00029 template <class ACE_LOCK, class TYPE> ACE_INLINE TYPE
00030 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator-- (void)
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 }
00036 
00037 template <class ACE_LOCK, class TYPE> ACE_INLINE TYPE
00038 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator-= (const TYPE &rhs)
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 }
00044 
00045 template <class ACE_LOCK, class TYPE> ACE_INLINE
00046 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::ACE_Atomic_Op_Ex (const ACE_Atomic_Op_Ex<ACE_LOCK, TYPE> &rhs)
00047   : mutex_ (rhs.mutex_)
00048 {
00049 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::ACE_Atomic_Op_Ex");
00050   *this = rhs; // Invoke the assignment operator.
00051 }
00052 
00053 template <class ACE_LOCK, class TYPE> ACE_INLINE TYPE
00054 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator++ (int)
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 }
00060 
00061 template <class ACE_LOCK, class TYPE> ACE_INLINE TYPE
00062 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator-- (int)
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 }
00068 
00069 template <class ACE_LOCK, class TYPE> ACE_INLINE bool
00070 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator== (const TYPE &rhs) const
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 }
00076 
00077 template <class ACE_LOCK, class TYPE> ACE_INLINE bool
00078 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator!= (const TYPE &rhs) const
00079 {
00080 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator!=");
00081   return !(*this == rhs);
00082 }
00083 
00084 template <class ACE_LOCK, class TYPE> ACE_INLINE bool
00085 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator>= (const TYPE &rhs) const
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 }
00091 
00092 template <class ACE_LOCK, class TYPE> ACE_INLINE bool
00093 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator> (const TYPE &rhs) const
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 }
00099 
00100 template <class ACE_LOCK, class TYPE> ACE_INLINE bool
00101 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator<= (const TYPE &rhs) const
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 }
00107 
00108 template <class ACE_LOCK, class TYPE> ACE_INLINE bool
00109 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator< (const TYPE &rhs) const
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 }
00115 
00116 template <class ACE_LOCK, class TYPE> ACE_INLINE ACE_Atomic_Op_Ex<ACE_LOCK, TYPE> &
00117 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator= (const ACE_Atomic_Op_Ex<ACE_LOCK, TYPE> &rhs)
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 }
00129 
00130 template <class ACE_LOCK, class TYPE> ACE_INLINE TYPE
00131 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::value (void) const
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 }
00137 
00138 template <class ACE_LOCK, class TYPE> ACE_INLINE TYPE &
00139 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::value_i (void)
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 }
00147 
00148 template <class ACE_LOCK, class TYPE> ACE_INLINE ACE_Atomic_Op_Ex<ACE_LOCK, TYPE> &
00149 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator= (const TYPE &rhs)
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 }
00156 
00157 //
00158 // ACE_Atomic_Op inline functions
00159 //
00160 
00161 template <class ACE_LOCK, class TYPE> ACE_INLINE
00162 ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op
00163   (const ACE_Atomic_Op<ACE_LOCK, TYPE> &rhs)
00164   : impl_ (this->own_mutex_, rhs.value ())
00165 {
00166 // ACE_TRACE ("ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op");
00167 }
00168 
00169 
00170 template <class ACE_LOCK, class TYPE> ACE_INLINE ACE_Atomic_Op<ACE_LOCK, TYPE> &
00171 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator= (const TYPE &i)
00172 {
00173   this->impl_ = i;
00174   return *this;
00175 }
00176 
00177 template <class ACE_LOCK, class TYPE> ACE_INLINE ACE_Atomic_Op<ACE_LOCK, TYPE> &
00178 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator= (const ACE_Atomic_Op<ACE_LOCK, TYPE> &rhs)
00179 {
00180   this->impl_ = rhs.impl_;
00181   return *this;
00182 }
00183 
00184 template <class ACE_LOCK, class TYPE> ACE_INLINE TYPE
00185 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator++ (void)
00186 {
00187   return ++this->impl_;
00188 }
00189 
00190 template <class ACE_LOCK, class TYPE> ACE_INLINE TYPE
00191 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator++ (int)
00192 {
00193   return this->impl_++;
00194 }
00195 
00196 template <class ACE_LOCK, class TYPE> ACE_INLINE TYPE
00197 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator+= (const TYPE &rhs)
00198 {
00199   return this->impl_ += rhs;
00200 }
00201 
00202 template <class ACE_LOCK, class TYPE> ACE_INLINE TYPE
00203 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator-- (void)
00204 {
00205   return --this->impl_;
00206 }
00207 
00208 template <class ACE_LOCK, class TYPE> ACE_INLINE TYPE
00209 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator-- (int)
00210 {
00211   return this->impl_--;
00212 }
00213 
00214 template <class ACE_LOCK, class TYPE> ACE_INLINE TYPE
00215 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator-= (const TYPE &rhs)
00216 {
00217   return this->impl_ -= rhs;
00218 }
00219 
00220 template <class ACE_LOCK, class TYPE> ACE_INLINE bool
00221 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator== (const TYPE &rhs) const
00222 {
00223   return this->impl_ == rhs;
00224 }
00225 
00226 template <class ACE_LOCK, class TYPE> ACE_INLINE bool
00227 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator!= (const TYPE &rhs) const
00228 {
00229   return this->impl_ != rhs;
00230 }
00231 
00232 template <class ACE_LOCK, class TYPE> ACE_INLINE bool
00233 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator>= (const TYPE &rhs) const
00234 {
00235   return this->impl_ >= rhs;
00236 }
00237 
00238 template <class ACE_LOCK, class TYPE> ACE_INLINE bool
00239 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator> (const TYPE &rhs) const
00240 {
00241   return this->impl_ > rhs;
00242 }
00243 
00244 template <class ACE_LOCK, class TYPE> ACE_INLINE bool
00245 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator<= (const TYPE &rhs) const
00246 {
00247   return this->impl_ <= rhs;
00248 }
00249 
00250 template <class ACE_LOCK, class TYPE> ACE_INLINE bool
00251 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator< (const TYPE &rhs) const
00252 {
00253   return this->impl_ < rhs;
00254 }
00255 
00256 template <class ACE_LOCK, class TYPE> ACE_INLINE TYPE
00257 ACE_Atomic_Op<ACE_LOCK, TYPE>::value (void) const
00258 {
00259   return this->impl_.value ();
00260 }
00261 
00262 template <class ACE_LOCK, class TYPE> ACE_INLINE void
00263 ACE_Atomic_Op<ACE_LOCK, TYPE>::dump (void) const
00264 {
00265 #if defined (ACE_HAS_DUMP)
00266   this->impl_.dump ();
00267 #endif /* ACE_HAS_DUMP */
00268   return;
00269 }
00270 
00271 template <class ACE_LOCK, class TYPE> ACE_INLINE ACE_LOCK &
00272 ACE_Atomic_Op<ACE_LOCK, TYPE>::mutex (void)
00273 {
00274   return this->own_mutex_;
00275 }
00276 
00277 template <class ACE_LOCK, class TYPE> ACE_INLINE TYPE &
00278 ACE_Atomic_Op<ACE_LOCK, TYPE>::value_i (void)
00279 {
00280   return this->impl_.value_i ();
00281 }
00282 
00283 ACE_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 09:41:46 2006 for ACE by doxygen 1.3.6