Go to the documentation of this file.00001 #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SYNC_HPP_INCLUDED
00002 #define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SYNC_HPP_INCLUDED
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #if defined( __ia64__ ) && defined( __INTEL_COMPILER )
00019 # include <ia64intrin.h>
00020 #endif
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 long operator++()
00035 {
00036 return __sync_add_and_fetch( &value_, 1 );
00037 }
00038
00039 long operator--()
00040 {
00041 return __sync_add_and_fetch( &value_, -1 );
00042 }
00043
00044 operator long() const
00045 {
00046 return __sync_fetch_and_add( &value_, 0 );
00047 }
00048
00049 private:
00050
00051 atomic_count(atomic_count const &);
00052 atomic_count & operator=(atomic_count const &);
00053
00054 mutable long value_;
00055 };
00056
00057 }
00058
00059 }
00060
00061 #endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SYNC_HPP_INCLUDED