00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _DECAF_UTIL_CONCURRENT_ATOMIC_ATOMICINTEGER_H_
00019 #define _DECAF_UTIL_CONCURRENT_ATOMIC_ATOMICINTEGER_H_
00020
00021 #include <decaf/util/Config.h>
00022 #include <decaf/lang/Number.h>
00023 #include <string>
00024
00025 namespace decaf {
00026 namespace util {
00027 namespace concurrent {
00028 namespace atomic {
00029
00037 class DECAF_API AtomicInteger : public decaf::lang::Number {
00038 private:
00039
00040 volatile int value;
00041
00042 private:
00043
00044 AtomicInteger(const AtomicInteger&);
00045 AtomicInteger& operator= (const AtomicInteger&);
00046
00047 public:
00048
00052 AtomicInteger();
00053
00058 AtomicInteger( int initialValue );
00059
00060 virtual ~AtomicInteger() {}
00061
00066 int get() const {
00067 return this->value;
00068 }
00069
00074 void set( int newValue ) {
00075 this->value = newValue;
00076 }
00077
00083 int getAndSet( int newValue );
00084
00094 bool compareAndSet( int expect, int update );
00095
00100 int getAndIncrement();
00101
00106 int getAndDecrement();
00107
00113 int getAndAdd( int delta );
00114
00119 int incrementAndGet();
00120
00125 int decrementAndGet();
00126
00132 int addAndGet( int delta );
00133
00138 std::string toString() const;
00139
00147 int intValue() const;
00148
00156 long long longValue() const;
00157
00165 float floatValue() const;
00166
00174 double doubleValue() const;
00175
00176 };
00177
00178 }}}}
00179
00180 #endif