Document return values
[ACE_TAO.git] / ACE / ace / Atomic_Op_GCC_T.h
blob751387f9ce7779cd4f7b2f6145f292737f74e31a
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Atomic_Op_GCC_T.h
7 * @author Johnny Willemsen <jwillemsen@remedy.nl
8 */
9 //=============================================================================
11 #ifndef ACE_ATOMIC_OP_GCC_T_H
12 #define ACE_ATOMIC_OP_GCC_T_H
13 #include /**/ "ace/pre.h"
15 #include /**/ "ace/config-all.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 # pragma once
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include "ace/Thread_Mutex.h"
22 #include "ace/ACE_export.h"
24 #if defined (ACE_HAS_GCC_ATOMIC_BUILTINS) && (ACE_HAS_GCC_ATOMIC_BUILTINS == 1)
26 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
28 /**
29 * @brief Specialization of ACE_Atomic_Op for platforms that
30 * support atomic integer operations.
32 * Specialization of ACE_Atomic_Op for platforms that support atomic
33 * integer operations.
35 template<typename T>
36 class ACE_Export ACE_Atomic_Op_GCC
38 public:
39 /// Atomically pre-increment @c value_.
40 T operator++ ();
42 /// Atomically post-increment @c value_.
43 T operator++ (int);
45 /// Atomically increment @c value_ by rhs.
46 T operator+= (T rhs);
48 /// Atomically pre-decrement @c value_.
49 T operator-- ();
51 /// Atomically post-decrement @c value_.
52 T operator-- (int);
54 /// Atomically decrement @c value_ by rhs.
55 T operator-= (T rhs);
57 /// Atomically compare @c value_ with rhs.
58 bool operator== (T rhs) const;
60 /// Atomically compare @c value_ with rhs.
61 bool operator!= (T rhs) const;
63 /// Atomically check if @c value_ greater than or equal to rhs.
64 bool operator>= (T rhs) const;
66 /// Atomically check if @c value_ greater than rhs.
67 bool operator> (T rhs) const;
69 /// Atomically check if @c value_ less than or equal to rhs.
70 bool operator<= (T rhs) const;
72 /// Atomically check if @c value_ less than rhs.
73 bool operator< (T rhs) const;
75 /// Exchange value with @a newval.
76 T exchange (T newval);
78 /// Explicitly return @c value_.
79 T value () const;
81 /// Dump the state of an object.
82 void dump () const;
84 /// Explicitly return @c value_ (by reference).
85 volatile T &value_i ();
87 // ACE_ALLOC_HOOK_DECLARE;
88 // Declare the dynamic allocation hooks.
90 protected:
91 /// Atomically assign rhs to @c value_.
92 ACE_Atomic_Op_GCC<T> &operator= (T rhs);
94 /// Atomically assign <rhs> to @c value_.
95 ACE_Atomic_Op_GCC<T> &operator= (const ACE_Atomic_Op_GCC<T> &rhs);
97 /// Initialize @c value_ to 0.
98 ACE_Atomic_Op_GCC ();
100 /// Initialize @c value_ to c.
101 ACE_Atomic_Op_GCC (T c);
103 /// Manage copying...
104 ACE_Atomic_Op_GCC (const ACE_Atomic_Op_GCC<T> &c);
106 private:
107 // This function cannot be supported by this template specialization.
108 // If you need access to an underlying lock, use the ACE_Atomic_Op_Ex
109 // template instead.
110 ACE_Thread_Mutex &mutex ();
112 private:
113 /// Current object decorated by the atomic op.
114 volatile T value_;
117 ACE_END_VERSIONED_NAMESPACE_DECL
119 #if defined (__ACE_INLINE__)
120 #include "ace/Atomic_Op_GCC_T.inl"
121 #endif /* __ACE_INLINE__ */
123 #include "ace/Atomic_Op_GCC_T.cpp"
125 #endif /* ACE_HAS_GCC_ATOMIC_BUILTINS */
127 #include /**/ "ace/post.h"
128 #endif /*ACE_ATOMIC_OP_GCC_T_H*/