atomic_count_win32.hpp
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 // MS compatible compilers support #pragma once
00005 
00006 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
00007 # pragma once
00008 #endif
00009 
00010 //
00011 //  boost/detail/atomic_count_win32.hpp
00012 //
00013 //  Copyright (c) 2001-2005 Peter Dimov
00014 //
00015 // Distributed under the Boost Software License, Version 1.0. (See
00016 // accompanying file LICENSE_1_0.txt or copy at
00017 // http://www.boost.org/LICENSE_1_0.txt)
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 } // namespace detail
00060 
00061 } // namespace boost
00062 
00063 #endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED


appl
Author(s): petercai
autogenerated on Tue Jan 7 2014 11:02:28