00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _DECAF_INTERNAL_UTIL_CONCURRENT_ATOMICS_H_
00019 #define _DECAF_INTERNAL_UTIL_CONCURRENT_ATOMICS_H_
00020
00021 #include <decaf/util/Config.h>
00022
00023 namespace decaf {
00024 namespace internal {
00025 namespace util {
00026 namespace concurrent {
00027
00028 class Threading;
00029
00030 class DECAF_API Atomics {
00031 private:
00032
00033 Atomics();
00034 Atomics(const Atomics&);
00035 Atomics& operator= (const Atomics&);
00036
00037 public:
00038
00039 template<typename T>
00040 static bool compareAndSwap(T*& target, T* expect, T* update) {
00041
00042 return Atomics::compareAndSet((volatile void**)&target, (void*)expect, (void*)update);
00043 }
00044
00045 public:
00046
00047 static bool compareAndSet32(volatile int* target, int expect, int update);
00048 static bool compareAndSet(volatile void** target, void* expect, void* update);
00049
00050 static void* getAndSet(volatile void** target, void* value);
00051 static int getAndSet(volatile int* target, int value);
00052
00053 static int getAndIncrement(volatile int* target);
00054 static int getAndDecrement(volatile int* target);
00055
00056 static int getAndAdd(volatile int* target, int delta);
00057 static int addAndGet(volatile int* target, int delta);
00058
00059 static int incrementAndGet(volatile int* target);
00060 static int decrementAndGet(volatile int* target);
00061
00062 private:
00063
00064 static void initialize();
00065 static void shutdown();
00066
00067 friend class Threading;
00068 };
00069
00070 }}}}
00071
00072 #endif