Debian Codegraph @

Modules/ThirdParty/VNL/src/vxl/vcl/internal/vcl_atomic_count_solaris.h

raw
1 #ifndef vcl_atomic_count_solaris_h_
2 #define vcl_atomic_count_solaris_h_
3 //:
4 // \file
5 // \brief thread/SMP safe reference counter
6 // \author www.boost.org
7 // \verbatim
8 // Modifications
9 // Gehua Yang (DualAlign) - 28 Aug. 2008 - first port from Boost 1.36.0
10 // \endverbatim
11 //
12 // boost/detail/atomic_count_solaris.hpp
13 // based on: boost/detail/atomic_count_win32.hpp
14 //
15 // Copyright (c) 2001-2005 Peter Dimov
16 // Copyright (c) 2006 Michael van der Westhuizen
17 //
18 // Distributed under the Boost Software License, Version 1.0. (See
19 // accompanying file LICENSE_1_0.txt or copy at
20 // http://www.boost.org/LICENSE_1_0.txt)
21 //
22
23 #include <atomic.h>
24
25 class vcl_atomic_count
26 {
27 public:
28
29 explicit vcl_atomic_count( uint32_t v ): value_( v )
30 {
31 }
32
33 long operator++()
34 {
35 return atomic_inc_32_nv( &value_ );
36 }
37
38 long operator--()
39 {
40 return atomic_dec_32_nv( &value_ );
41 }
42
43 operator uint32_t() const
44 {
45 return static_cast<uint32_t const volatile &>( value_ );
46 }
47
48 private:
49
50 vcl_atomic_count( vcl_atomic_count const & );
51 vcl_atomic_count & operator=( vcl_atomic_count const & );
52
53 uint32_t value_;
54 };
55
56 #endif // #ifndef vcl_atomic_count_solaris_h_