00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _DECAF_UTIL_CONCURRENT_ATOMIC_ATOMICBOOLEAN_H_
00019 #define _DECAF_UTIL_CONCURRENT_ATOMIC_ATOMICBOOLEAN_H_
00020
00021 #include <string>
00022 #include <decaf/util/Config.h>
00023
00024 namespace decaf {
00025 namespace util {
00026 namespace concurrent {
00027 namespace atomic {
00028
00034 class DECAF_API AtomicBoolean {
00035 private:
00036
00037 volatile int value;
00038
00039 private:
00040
00041 AtomicBoolean(const AtomicBoolean&);
00042 AtomicBoolean& operator= (const AtomicBoolean&);
00043
00044 public:
00045
00049 AtomicBoolean();
00050
00055 AtomicBoolean(bool initialValue);
00056
00057 virtual ~AtomicBoolean() {}
00058
00063 bool get() const {
00064 return value == 0 ? false : true;
00065 }
00066
00071 void set(bool newValue) {
00072 this->value = newValue ? 1 : 0;
00073 }
00074
00084 bool compareAndSet(bool expect, bool update);
00085
00092 bool getAndSet(bool newValue);
00093
00098 std::string toString() const;
00099
00100 };
00101
00102 }}}}
00103
00104 #endif