ace/coil/atomic.h
Go to the documentation of this file.
1 // -*- C++ -*-
19 #ifndef COIL_ATOMIC_H
20 
21 #include <coil/Mutex.h>
22 #include <coil/Guard.h>
23 #define COIL_USES_ATOMIC_OP coil::Mutex __mutex;
24 
25 #define atomic_add(x, y) \
26  { \
27  coil::Guard<coil::Mutex> guard(__mutex); \
28  *x = *x + y; \
29  }
30 
31 #define atomic_incr(x) \
32  { \
33  coil::Guard<coil::Mutex> guard(__mutex); \
34  ++(*x); \
35  }
36 
37 #define atomic_decr(x) \
38  { \
39  coil::Guard<coil::Mutex> guard(__mutex); \
40  --(*x); \
41  }
42 
43 int exchange_add(int* x, int y, coil::Mutex* mutex)
44 {
45  coil::Guard<coil::Mutex> guard(*mutex);
46  int tmp(*x);
47  *x = *x + y;
48  return tmp;
49 }
50 
51 #define atomic_exchange_add(x, y) \
52  exchange_add(x, y, &__mutex)
53 
54 #endif // COIL_ATOMIC_H
Mutex class.
int exchange_add(int *x, int y, coil::Mutex *mutex)


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Jun 10 2019 14:07:50