Go to the documentation of this file.00001 #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED
00002 #define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED
00003
00004
00005
00006 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
00007 # pragma once
00008 #endif
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <boost/detail/interlocked.hpp>
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 }
00035
00036 long operator++()
00037 {
00038 return BOOST_INTERLOCKED_INCREMENT( &value_ );
00039 }
00040
00041 long operator--()
00042 {
00043 return BOOST_INTERLOCKED_DECREMENT( &value_ );
00044 }
00045
00046 operator long() const
00047 {
00048 return static_cast<long const volatile &>( value_ );
00049 }
00050
00051 private:
00052
00053 atomic_count( atomic_count const & );
00054 atomic_count & operator=( atomic_count const & );
00055
00056 long value_;
00057 };
00058
00059 }
00060
00061 }
00062
00063 #endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED