Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef ACE_ATOMIC_OP_H
00014 #define ACE_ATOMIC_OP_H
00015 #include "ace/pre.h"
00016
00017 #include "ace/config-all.h"
00018
00019 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00020 # pragma once
00021 #endif
00022
00023 #include "ace/Thread_Mutex.h"
00024
00025
00026 #include "ace/Atomic_Op_T.h"
00027
00028
00029
00030 #if defined (ACE_HAS_THREADS)
00031 # if defined (WIN32)
00032 # if defined (ACE_HAS_INTRINSIC_INTERLOCKED)
00033 # define ACE_HAS_BUILTIN_ATOMIC_OP
00034 # endif
00035 # if defined (ACE_HAS_INTERLOCKED_EXCHANGEADD)
00036 # define ACE_HAS_BUILTIN_ATOMIC_OP
00037 # else
00038
00039
00040 # if (defined (_MSC_VER) && defined (_M_IX86)) || defined (__BORLANDC__)
00041 # define ACE_HAS_BUILTIN_ATOMIC_OP
00042 # endif
00043 # endif
00044 # elif defined (ACE_HAS_INTEL_ASSEMBLY)
00045 # define ACE_HAS_BUILTIN_ATOMIC_OP
00046 # elif defined (ACE_HAS_VXATOMICLIB)
00047 # define ACE_HAS_BUILTIN_ATOMIC_OP
00048 # elif defined (ACE_HAS_SOLARIS_ATOMIC_LIB) && !defined (ACE_HAS_BUILTIN_ATOMIC_OP)
00049 # define ACE_HAS_BUILTIN_ATOMIC_OP
00050 # endif
00051 #endif
00052
00053
00054 #if defined (ACE_HAS_GCC_ATOMIC_BUILTINS) && (ACE_HAS_GCC_ATOMIC_BUILTINS == 1)
00055 # undef ACE_HAS_BUILTIN_ATOMIC_OP
00056 #endif
00057
00058
00059 #include "ace/Atomic_Op_GCC_T.h"
00060
00061 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00062
00063 #if defined (ACE_HAS_BUILTIN_ATOMIC_OP)
00064
00065
00066
00067
00068
00069
00070
00071
00072 template<>
00073 class ACE_Export ACE_Atomic_Op<ACE_Thread_Mutex, long>
00074 {
00075 public:
00076
00077 ACE_Atomic_Op (void);
00078
00079
00080 ACE_Atomic_Op (long c);
00081
00082
00083 ACE_Atomic_Op (const ACE_Atomic_Op<ACE_Thread_Mutex, long> &c);
00084
00085
00086 long operator++ (void);
00087
00088
00089 long operator++ (int);
00090
00091
00092 long operator+= (long rhs);
00093
00094
00095 long operator-- (void);
00096
00097
00098 long operator-- (int);
00099
00100
00101 long operator-= (long rhs);
00102
00103
00104 bool operator== (long rhs) const;
00105
00106
00107 bool operator!= (long rhs) const;
00108
00109
00110 bool operator>= (long rhs) const;
00111
00112
00113 bool operator> (long rhs) const;
00114
00115
00116 bool operator<= (long rhs) const;
00117
00118
00119 bool operator< (long rhs) const;
00120
00121
00122 ACE_Atomic_Op<ACE_Thread_Mutex, long> &operator= (long rhs);
00123
00124
00125 ACE_Atomic_Op<ACE_Thread_Mutex, long> &operator= (const ACE_Atomic_Op<ACE_Thread_Mutex, long> &rhs);
00126
00127
00128 long value (void) const;
00129
00130
00131 void dump (void) const;
00132
00133
00134 volatile long &value_i (void);
00135
00136
00137
00138
00139
00140
00141 static void init_functions (void);
00142
00143 private:
00144
00145
00146
00147
00148 ACE_Thread_Mutex &mutex (void);
00149
00150 private:
00151
00152
00153 volatile long value_;
00154
00155
00156 static long (*increment_fn_) (volatile long *);
00157 static long (*decrement_fn_) (volatile long *);
00158 static long (*exchange_fn_) (volatile long *, long);
00159 static long (*exchange_add_fn_) (volatile long *, long);
00160 };
00161
00162
00163
00164
00165
00166
00167
00168
00169 template<>
00170 class ACE_Export ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>
00171 {
00172 public:
00173
00174 ACE_Atomic_Op (void);
00175
00176
00177 ACE_Atomic_Op (unsigned long c);
00178
00179
00180 ACE_Atomic_Op (const ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long> &c);
00181
00182
00183 unsigned long operator++ (void);
00184
00185
00186 unsigned long operator++ (int);
00187
00188
00189 unsigned long operator+= (unsigned long rhs);
00190
00191
00192 unsigned long operator-- (void);
00193
00194
00195 unsigned long operator-- (int);
00196
00197
00198 unsigned long operator-= (unsigned long rhs);
00199
00200
00201 bool operator== (unsigned long rhs) const;
00202
00203
00204 bool operator!= (unsigned long rhs) const;
00205
00206
00207 bool operator>= (unsigned long rhs) const;
00208
00209
00210 bool operator> (unsigned long rhs) const;
00211
00212
00213 bool operator<= (unsigned long rhs) const;
00214
00215
00216 bool operator< (unsigned long rhs) const;
00217
00218
00219 ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long> &operator= (unsigned long rhs);
00220
00221
00222 ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long> &operator= (const ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long> &rhs);
00223
00224
00225 unsigned long value (void) const;
00226
00227
00228 void dump (void) const;
00229
00230
00231 volatile unsigned long &value_i (void);
00232
00233
00234
00235
00236
00237
00238 static void init_functions (void);
00239
00240 private:
00241
00242
00243
00244
00245 ACE_Thread_Mutex &mutex (void);
00246
00247 private:
00248
00249
00250 volatile unsigned long value_;
00251
00252
00253 static long (*increment_fn_) (volatile long *);
00254 static long (*decrement_fn_) (volatile long *);
00255 static long (*exchange_fn_) (volatile long *, long);
00256 static long (*exchange_add_fn_) (volatile long *, long);
00257 };
00258
00259 #endif
00260
00261 #if defined (ACE_HAS_GCC_ATOMIC_BUILTINS) && (ACE_HAS_GCC_ATOMIC_BUILTINS == 1)
00262
00263 template<>
00264 class ACE_Export ACE_Atomic_Op<ACE_Thread_Mutex, int>
00265 : public ACE_Atomic_Op_GCC<int>
00266 {
00267 public:
00268 ACE_Atomic_Op (void);
00269 ACE_Atomic_Op (int c);
00270 ACE_Atomic_Op (const ACE_Atomic_Op<ACE_Thread_Mutex, int> &c);
00271 ACE_Atomic_Op<ACE_Thread_Mutex, int> &operator= (int rhs);
00272 };
00273
00274 template<>
00275 class ACE_Export ACE_Atomic_Op<ACE_Thread_Mutex, unsigned int>
00276 : public ACE_Atomic_Op_GCC<unsigned int>
00277 {
00278 public:
00279 ACE_Atomic_Op (void);
00280 ACE_Atomic_Op (unsigned int c);
00281 ACE_Atomic_Op (const ACE_Atomic_Op<ACE_Thread_Mutex, unsigned> &c);
00282 ACE_Atomic_Op<ACE_Thread_Mutex, unsigned int> &operator= (unsigned int rhs);
00283 };
00284
00285
00286
00287 template<>
00288 class ACE_Export ACE_Atomic_Op<ACE_Thread_Mutex, long>
00289 : public ACE_Atomic_Op_GCC<long>
00290 {
00291 public:
00292 ACE_Atomic_Op (void);
00293 ACE_Atomic_Op (long c);
00294 ACE_Atomic_Op (const ACE_Atomic_Op<ACE_Thread_Mutex, long> &c);
00295 ACE_Atomic_Op<ACE_Thread_Mutex, long> &operator= (long rhs);
00296 };
00297
00298 template<>
00299 class ACE_Export ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>
00300 : public ACE_Atomic_Op_GCC<unsigned long>
00301 {
00302 public:
00303 ACE_Atomic_Op (void);
00304 ACE_Atomic_Op (unsigned long c);
00305 ACE_Atomic_Op (const ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long> &c);
00306 ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long> &operator= (unsigned long rhs);
00307 };
00308
00309 #if !defined (ACE_LACKS_GCC_ATOMIC_BUILTINS_2)
00310 template<>
00311 class ACE_Export ACE_Atomic_Op<ACE_Thread_Mutex, short>
00312 : public ACE_Atomic_Op_GCC<short>
00313 {
00314 public:
00315 ACE_Atomic_Op (void);
00316 ACE_Atomic_Op (short c);
00317 ACE_Atomic_Op (const ACE_Atomic_Op<ACE_Thread_Mutex, short> &c);
00318 ACE_Atomic_Op<ACE_Thread_Mutex, short> &operator= (short rhs);
00319 };
00320
00321 template<>
00322 class ACE_Export ACE_Atomic_Op<ACE_Thread_Mutex, unsigned short>
00323 : public ACE_Atomic_Op_GCC<unsigned short>
00324 {
00325 public:
00326 ACE_Atomic_Op (void);
00327 ACE_Atomic_Op (unsigned short c);
00328 ACE_Atomic_Op (const ACE_Atomic_Op<ACE_Thread_Mutex, unsigned short> &c);
00329 ACE_Atomic_Op<ACE_Thread_Mutex, unsigned short> &operator= (unsigned short rhs);
00330 };
00331 #endif
00332
00333 #if !defined (ACE_LACKS_GCC_ATOMIC_BUILTINS_1)
00334 template<>
00335 class ACE_Export ACE_Atomic_Op<ACE_Thread_Mutex, bool>
00336 : public ACE_Atomic_Op_GCC<bool>
00337 {
00338 public:
00339 ACE_Atomic_Op (void);
00340 ACE_Atomic_Op (bool c);
00341 ACE_Atomic_Op (const ACE_Atomic_Op<ACE_Thread_Mutex, bool> &c);
00342 ACE_Atomic_Op<ACE_Thread_Mutex, bool> &operator= (bool rhs);
00343 };
00344 #endif
00345
00346 #endif
00347
00348 ACE_END_VERSIONED_NAMESPACE_DECL
00349
00350 #if defined (__ACE_INLINE__)
00351 #include "ace/Atomic_Op.inl"
00352 #endif
00353
00354 #include "ace/post.h"
00355 #endif