]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/smart_ptr/detail/atomic_count_win32.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / smart_ptr / detail / atomic_count_win32.hpp
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 //
11 // boost/detail/atomic_count_win32.hpp
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
20 #include <boost/smart_ptr/detail/sp_interlocked.hpp>
21
22 #if defined(BOOST_SP_REPORT_IMPLEMENTATION)
23
24 #include <boost/config/pragma_message.hpp>
25 BOOST_PRAGMA_MESSAGE("Using Win32 atomic_count")
26
27 #endif
28
29 namespace boost
30 {
31
32 namespace detail
33 {
34
35 class atomic_count
36 {
37 public:
38
39 explicit atomic_count( long v ): value_( v )
40 {
41 }
42
43 long operator++()
44 {
45 return BOOST_SP_INTERLOCKED_INCREMENT( &value_ );
46 }
47
48 long operator--()
49 {
50 return BOOST_SP_INTERLOCKED_DECREMENT( &value_ );
51 }
52
53 operator long() const
54 {
55 return static_cast<long const volatile &>( value_ );
56 }
57
58 private:
59
60 atomic_count( atomic_count const & );
61 atomic_count & operator=( atomic_count const & );
62
63 long value_;
64 };
65
66 } // namespace detail
67
68 } // namespace boost
69
70 #endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED