00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _interlockcount_h
00024 #define _interlockcount_h
00025
00026 #include <spl/types.h>
00027 #include <spl/Debug.h>
00028
00039 class InterlockCounter
00040 {
00041 private:
00042 volatile int32 _atomic;
00043
00044 public:
00045
00050 InterlockCounter(int32 value = 0) throw();
00051
00053 ~InterlockCounter() throw();
00054
00056 InterlockCounter(const InterlockCounter& other) throw();
00057
00059 InterlockCounter& operator =(const InterlockCounter& other) throw();
00060
00062 int32 operator++() throw();
00063
00065 int32 operator++(int) throw();
00066
00068 int32 operator--() throw();
00069
00071 int32 operator--(int) throw();
00072
00074 int32 operator+=(int32 delta) throw();
00075
00077 int32 operator-=(int32 delta) throw();
00078
00080 int32 operator+(int32 delta) const throw();
00081
00083 int32 operator-(int32 delta) const throw();
00084
00086 int32 operator=(int32 value) throw();
00087
00089 int32 Set(int32 value) throw();
00090
00092 int32 Swap(int32 value) throw();
00093
00094 inline bool operator >(int32 i) const
00095 {
00096 return Get() > i;
00097 }
00098
00099 inline bool operator >=(int32 i) const
00100 {
00101 return Get() >= i;
00102 }
00103
00104 inline bool operator <(int32 i) const
00105 {
00106 return Get() < i;
00107 }
00108
00109 inline bool operator <=(int32 i) const
00110 {
00111 return Get() <= i;
00112 }
00113
00114 inline bool operator !=(int32 i) const
00115 {
00116 return Get() != i;
00117 }
00118
00126 int32 TestAndSet(int32 value, int32 comparand) throw();
00127
00129 int32 Get() const throw();
00130
00132 inline operator int32() const throw()
00133 {
00134 return Get();
00135 }
00136 };
00137
00138 inline void ValidateType(const InterlockCounter& i)
00139 {
00140 }
00141
00142 REGISTER_TYPEOF( 458, InterlockCounter );
00143
00146 #endif