Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 1 | #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED |
| 2 | #define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED |
| 3 | |
| 4 | // MS compatible compilers support #pragma once |
| 5 | |
| 6 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) |
| 7 | # pragma once |
| 8 | #endif |
| 9 | |
| 10 | // |
Jeff Thompson | 9939dcd | 2013-10-15 15:12:24 -0700 | [diff] [blame^] | 11 | // ndnboost/detail/atomic_count_win32.hpp |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 12 | // |
| 13 | // Copyright (c) 2001-2005 Peter Dimov |
| 14 | // |
| 15 | // Distributed under the Boost Software License, Version 1.0. (See |
| 16 | // accompanying file LICENSE_1_0.txt or copy at |
| 17 | // http://www.boost.org/LICENSE_1_0.txt) |
| 18 | // |
| 19 | |
Jeff Thompson | 2277ce5 | 2013-08-01 17:34:11 -0700 | [diff] [blame] | 20 | #include <ndnboost/detail/interlocked.hpp> |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 21 | |
| 22 | namespace ndnboost |
| 23 | { |
| 24 | |
| 25 | namespace detail |
| 26 | { |
| 27 | |
| 28 | class atomic_count |
| 29 | { |
| 30 | public: |
| 31 | |
| 32 | explicit atomic_count( long v ): value_( v ) |
| 33 | { |
| 34 | } |
| 35 | |
| 36 | long operator++() |
| 37 | { |
| 38 | return BOOST_INTERLOCKED_INCREMENT( &value_ ); |
| 39 | } |
| 40 | |
| 41 | long operator--() |
| 42 | { |
| 43 | return BOOST_INTERLOCKED_DECREMENT( &value_ ); |
| 44 | } |
| 45 | |
| 46 | operator long() const |
| 47 | { |
| 48 | return static_cast<long const volatile &>( value_ ); |
| 49 | } |
| 50 | |
| 51 | private: |
| 52 | |
| 53 | atomic_count( atomic_count const & ); |
| 54 | atomic_count & operator=( atomic_count const & ); |
| 55 | |
| 56 | long value_; |
| 57 | }; |
| 58 | |
| 59 | } // namespace detail |
| 60 | |
| 61 | } // namespace ndnboost |
| 62 | |
| 63 | #endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED |