00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00025 #ifndef _UCOMMON_ATOMIC_H_
00026 #define _UCOMMON_ATOMIC_H_
00027
00028 #ifndef _UCOMMON_CONFIG_H_
00029 #include <ucommon/platform.h>
00030 #endif
00031
00032 NAMESPACE_UCOMMON
00033
00042 class __EXPORT atomic
00043 {
00044 public:
00048 static const bool simulated;
00049
00055 class __EXPORT counter
00056 {
00057 private:
00058 volatile long value;
00059
00060 public:
00061 counter(long initial = 0);
00062
00063 long operator++();
00064 long operator--();
00065 long operator+=(long offset);
00066 long operator-=(long offset);
00067
00068 inline operator long()
00069 {return (long)(value);};
00070
00071 inline long operator*()
00072 {return value;};
00073 };
00074
00080 class __EXPORT spinlock
00081 {
00082 private:
00083 volatile long value;
00084
00085 public:
00089 spinlock();
00090
00096 bool acquire(void);
00097
00101 void release(void);
00102 };
00103 };
00104
00105 END_NAMESPACE
00106
00107 #endif