00001 #ifndef BOOST_DETAIL_ATOMIC_COUNT_GCC_HPP_INCLUDED
00002 #define BOOST_DETAIL_ATOMIC_COUNT_GCC_HPP_INCLUDED
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <bits/atomicity.h>
00021
00022 namespace boost
00023 {
00024
00025 namespace detail
00026 {
00027
00028 class atomic_count
00029 {
00030 public:
00031
00032 explicit atomic_count(long v) : value_(v) {}
00033
00034 void operator++()
00035 {
00036 __atomic_add(&value_, 1);
00037 }
00038
00039 long operator--()
00040 {
00041 return !__exchange_and_add(&value_, -1);
00042 }
00043
00044 operator long() const
00045 {
00046 return __exchange_and_add(&value_, 0);
00047 }
00048
00049 private:
00050
00051 atomic_count(atomic_count const &);
00052 atomic_count & operator=(atomic_count const &);
00053
00054 _Atomic_word value_;
00055 };
00056
00057 }
00058
00059 }
00060
00061 #endif // #ifndef BOOST_DETAIL_ATOMIC_COUNT_GCC_HPP_INCLUDED