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