00001 #ifndef BOOST_DETAIL_ATOMIC_COUNT_LINUX_HPP_INCLUDED
00002 #define BOOST_DETAIL_ATOMIC_COUNT_LINUX_HPP_INCLUDED
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <asm/atomic.h>
00026
00027 namespace boost
00028 {
00029
00030 namespace detail
00031 {
00032
00033 class atomic_count
00034 {
00035 public:
00036
00037 explicit atomic_count(long v)
00038 {
00039 atomic_t init = ATOMIC_INIT(v);
00040 value_ = init;
00041 }
00042
00043 void operator++()
00044 {
00045 atomic_inc(&value_);
00046 }
00047
00048 long operator--()
00049 {
00050 return !atomic_dec_and_test(&value_);
00051 }
00052
00053 operator long() const
00054 {
00055 return atomic_read(&value_);
00056 }
00057
00058 private:
00059
00060 atomic_count(atomic_count const &);
00061 atomic_count & operator=(atomic_count const &);
00062
00063 atomic_t value_;
00064 };
00065
00066 }
00067
00068 }
00069
00070 #endif // #ifndef BOOST_DETAIL_ATOMIC_COUNT_LINUX_HPP_INCLUDED