Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:51:42

0001 #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SPIN_HPP_INCLUDED
0002 #define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SPIN_HPP_INCLUDED
0003 
0004 //
0005 //  boost/detail/atomic_count_spin.hpp
0006 //
0007 //  Copyright (c) 2013 Peter Dimov
0008 //
0009 //  Distributed under the Boost Software License, Version 1.0.
0010 //  See accompanying file LICENSE_1_0.txt or copy at
0011 //  http://www.boost.org/LICENSE_1_0.txt
0012 //
0013 
0014 #include <boost/smart_ptr/detail/spinlock_pool.hpp>
0015 
0016 #if defined(BOOST_SP_REPORT_IMPLEMENTATION)
0017 
0018 #include <boost/config/pragma_message.hpp>
0019 BOOST_PRAGMA_MESSAGE("Using spinlock-based atomic_count")
0020 
0021 #endif
0022 
0023 namespace boost
0024 {
0025 
0026 namespace detail
0027 {
0028 
0029 class atomic_count
0030 {
0031 private:
0032 
0033 public:
0034 
0035     explicit atomic_count( long v ): value_( v )
0036     {
0037     }
0038 
0039     long operator++()
0040     {
0041         spinlock_pool<0>::scoped_lock lock( &value_ );
0042         return ++value_;
0043     }
0044 
0045     long operator--()
0046     {
0047         spinlock_pool<0>::scoped_lock lock( &value_ );
0048         return --value_;
0049     }
0050 
0051     operator long() const
0052     {
0053         spinlock_pool<0>::scoped_lock lock( &value_ );
0054         return value_;
0055     }
0056 
0057 private:
0058 
0059     atomic_count(atomic_count const &);
0060     atomic_count & operator=(atomic_count const &);
0061 
0062     long value_;
0063 };
0064 
0065 } // namespace detail
0066 
0067 } // namespace boost
0068 
0069 #endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SPIN_HPP_INCLUDED