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