]> git.lyx.org Git - lyx.git/blob - boost/boost/detail/atomic_count_win32.hpp
major boost update
[lyx.git] / boost / boost / detail / atomic_count_win32.hpp
1 #ifndef BOOST_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED
2 #define BOOST_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED
3
4 #if _MSC_VER >= 1020
5 #pragma once
6 #endif
7
8 //
9 //  boost/detail/atomic_count_win32.hpp
10 //
11 //  Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
12 //
13 //  Permission to copy, use, modify, sell and distribute this software
14 //  is granted provided this copyright notice appears in all copies.
15 //  This software is provided "as is" without express or implied
16 //  warranty, and with no claim as to its suitability for any purpose.
17 //
18
19 #include <boost/detail/winapi.hpp>
20
21 namespace boost
22 {
23
24 namespace detail
25 {
26
27 class atomic_count
28 {
29 public:
30
31     explicit atomic_count(long v): value_(v)
32     {
33     }
34
35     long operator++()
36     {
37         return winapi::InterlockedIncrement(&value_);
38     }
39
40     long operator--()
41     {
42         return winapi::InterlockedDecrement(&value_);
43     }
44
45     operator long() const
46     {
47         return value_;
48     }
49
50 private:
51
52     atomic_count(atomic_count const &);
53     atomic_count & operator=(atomic_count const &);
54
55     volatile long value_;
56 };
57
58 } // namespace detail
59
60 } // namespace boost
61
62 #endif // #ifndef BOOST_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED