2 #include "ace/Guard_T.h"
6 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
9 // ACE_Atomic_Op_Ex inline functions
12 template <class ACE_LOCK, class TYPE>
14 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator++ ()
16 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator++");
17 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_);
18 return ++this->value_;
21 template <class ACE_LOCK, class TYPE>
23 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator+= (
24 typename ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::arg_type rhs)
26 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator+=");
27 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_);
28 return this->value_ += rhs;
31 template <class ACE_LOCK, class TYPE>
33 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator-- ()
35 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator--");
36 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_);
37 return --this->value_;
40 template <class ACE_LOCK, class TYPE>
42 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator-= (
43 typename ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::arg_type rhs)
45 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator-=");
46 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_);
47 return this->value_ -= rhs;
50 template <class ACE_LOCK, class TYPE>
52 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::ACE_Atomic_Op_Ex (
53 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE> const & rhs)
55 , value_ (rhs.value ()) // rhs.value() returns atomically
57 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::ACE_Atomic_Op_Ex");
60 template <class ACE_LOCK, class TYPE>
62 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator++ (int)
64 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator++");
65 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_);
66 return this->value_++;
69 template <class ACE_LOCK, class TYPE>
71 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator-- (int)
73 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator--");
74 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_);
75 return this->value_--;
78 template <class ACE_LOCK, class TYPE>
80 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator== (
81 typename ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::arg_type rhs) const
83 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator==");
84 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, false);
85 return this->value_ == rhs;
88 template <class ACE_LOCK, class TYPE>
90 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator!= (
91 typename ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::arg_type rhs) const
93 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator!=");
94 return !(*this == rhs);
97 template <class ACE_LOCK, class TYPE>
99 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator>= (
100 typename ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::arg_type rhs) const
102 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator>=");
103 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, false);
104 return this->value_ >= rhs;
107 template <class ACE_LOCK, class TYPE>
109 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator> (
110 typename ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::arg_type rhs) const
112 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator>");
113 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, false);
114 return this->value_ > rhs;
117 template <class ACE_LOCK, class TYPE>
119 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator<= (
120 typename ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::arg_type rhs) const
122 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator<=");
123 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, false);
124 return this->value_ <= rhs;
127 template <class ACE_LOCK, class TYPE>
129 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator< (
130 typename ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::arg_type rhs) const
132 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator<");
133 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, false);
134 return this->value_ < rhs;
137 template <class ACE_LOCK, class TYPE>
138 ACE_INLINE ACE_Atomic_Op_Ex<ACE_LOCK, TYPE> &
139 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator= (
140 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE> const & rhs)
142 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator=");
144 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE> tmp (rhs);
146 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, *this);
147 std::swap (this->value_, tmp.value_);
152 template <class ACE_LOCK, class TYPE>
154 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::exchange (TYPE newval)
156 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::exchange");
157 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_);
158 std::swap (this->value_, newval);
162 template <class ACE_LOCK, class TYPE>
164 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::value () const
166 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::value");
167 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_);
171 template <class ACE_LOCK, class TYPE>
173 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::value_i ()
175 // Explicitly return <value_> (by reference). This gives the user
176 // full, unrestricted access to the underlying value. This method
177 // will usually be used in conjunction with explicit access to the
178 // lock. Use with care ;-)
182 template <class ACE_LOCK, class TYPE>
183 ACE_INLINE ACE_Atomic_Op_Ex<ACE_LOCK, TYPE> &
184 ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator= (
185 typename ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::arg_type rhs)
187 // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator=");
188 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, *this);
194 // ACE_Atomic_Op inline functions
197 template <class ACE_LOCK, class TYPE> ACE_INLINE
198 ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op (
199 ACE_Atomic_Op<ACE_LOCK, TYPE> const & rhs)
200 : impl_ (own_mutex_, rhs.value ())
202 // ACE_TRACE ("ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op");
206 template <class ACE_LOCK, class TYPE>
207 ACE_INLINE ACE_Atomic_Op<ACE_LOCK, TYPE> &
208 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator= (
209 typename ACE_Atomic_Op<ACE_LOCK, TYPE>::arg_type i)
215 template <class ACE_LOCK, class TYPE>
216 ACE_INLINE ACE_Atomic_Op<ACE_LOCK, TYPE> &
217 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator= (
218 ACE_Atomic_Op<ACE_LOCK, TYPE> const & rhs)
220 this->impl_ = rhs.impl_;
224 template <class ACE_LOCK, class TYPE>
226 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator++ ()
228 return ++this->impl_;
231 template <class ACE_LOCK, class TYPE>
233 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator++ (int)
235 return this->impl_++;
238 template <class ACE_LOCK, class TYPE>
240 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator+= (
241 typename ACE_Atomic_Op<ACE_LOCK, TYPE>::arg_type rhs)
243 return this->impl_ += rhs;
246 template <class ACE_LOCK, class TYPE>
248 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator-- ()
250 return --this->impl_;
253 template <class ACE_LOCK, class TYPE>
255 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator-- (int)
257 return this->impl_--;
260 template <class ACE_LOCK, class TYPE>
262 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator-= (
263 typename ACE_Atomic_Op<ACE_LOCK, TYPE>::arg_type rhs)
265 return this->impl_ -= rhs;
268 template <class ACE_LOCK, class TYPE>
270 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator== (
271 typename ACE_Atomic_Op<ACE_LOCK, TYPE>::arg_type rhs) const
273 return this->impl_ == rhs;
276 template <class ACE_LOCK, class TYPE>
278 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator!= (
279 typename ACE_Atomic_Op<ACE_LOCK, TYPE>::arg_type rhs) const
281 return this->impl_ != rhs;
284 template <class ACE_LOCK, class TYPE>
286 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator>= (
287 typename ACE_Atomic_Op<ACE_LOCK, TYPE>::arg_type rhs) const
289 return this->impl_ >= rhs;
292 template <class ACE_LOCK, class TYPE>
294 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator> (
295 typename ACE_Atomic_Op<ACE_LOCK, TYPE>::arg_type rhs) const
297 return this->impl_ > rhs;
300 template <class ACE_LOCK, class TYPE>
302 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator<= (
303 typename ACE_Atomic_Op<ACE_LOCK, TYPE>::arg_type rhs) const
305 return this->impl_ <= rhs;
308 template <class ACE_LOCK, class TYPE>
310 ACE_Atomic_Op<ACE_LOCK, TYPE>::operator< (
311 typename ACE_Atomic_Op<ACE_LOCK, TYPE>::arg_type rhs) const
313 return this->impl_ < rhs;
316 template <class ACE_LOCK, class TYPE>
318 ACE_Atomic_Op<ACE_LOCK, TYPE>::exchange (TYPE newval)
320 return this->impl_.exchange (newval);
323 template <class ACE_LOCK, class TYPE>
325 ACE_Atomic_Op<ACE_LOCK, TYPE>::value () const
327 return this->impl_.value ();
330 template <class ACE_LOCK, class TYPE>
332 ACE_Atomic_Op<ACE_LOCK, TYPE>::dump () const
334 #if defined (ACE_HAS_DUMP)
336 #endif /* ACE_HAS_DUMP */
339 template <class ACE_LOCK, class TYPE>
341 ACE_Atomic_Op<ACE_LOCK, TYPE>::value_i ()
343 return this->impl_.value_i ();
346 ACE_END_VERSIONED_NAMESPACE_DECL