File indexing completed on 2025-01-18 09:51:42
0001 #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED
0002 #define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED
0003
0004
0005
0006 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
0007 # pragma once
0008 #endif
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <boost/smart_ptr/detail/sp_interlocked.hpp>
0021
0022 #if defined(BOOST_SP_REPORT_IMPLEMENTATION)
0023
0024 #include <boost/config/pragma_message.hpp>
0025 BOOST_PRAGMA_MESSAGE("Using Win32 atomic_count")
0026
0027 #endif
0028
0029 namespace boost
0030 {
0031
0032 namespace detail
0033 {
0034
0035 class atomic_count
0036 {
0037 public:
0038
0039 explicit atomic_count( long v ): value_( v )
0040 {
0041 }
0042
0043 long operator++()
0044 {
0045 return BOOST_SP_INTERLOCKED_INCREMENT( &value_ );
0046 }
0047
0048 long operator--()
0049 {
0050 return BOOST_SP_INTERLOCKED_DECREMENT( &value_ );
0051 }
0052
0053 operator long() const
0054 {
0055 return static_cast<long const volatile &>( value_ );
0056 }
0057
0058 private:
0059
0060 atomic_count( atomic_count const & );
0061 atomic_count & operator=( atomic_count const & );
0062
0063 long value_;
0064 };
0065
0066 }
0067
0068 }
0069
0070 #endif