1 #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_POOL_HPP_INCLUDED
\r
2 #define BOOST_SMART_PTR_DETAIL_SPINLOCK_POOL_HPP_INCLUDED
\r
4 // MS compatible compilers support #pragma once
\r
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
\r
11 // boost/detail/spinlock_pool.hpp
\r
13 // Copyright (c) 2008 Peter Dimov
\r
15 // Distributed under the Boost Software License, Version 1.0.
\r
16 // See accompanying file LICENSE_1_0.txt or copy at
\r
17 // http://www.boost.org/LICENSE_1_0.txt)
\r
19 // spinlock_pool<0> is reserved for atomic<>, when/if it arrives
\r
20 // spinlock_pool<1> is reserved for shared_ptr reference counts
\r
21 // spinlock_pool<2> is reserved for shared_ptr atomic access
\r
24 #include <boost/config.hpp>
\r
25 #include <boost/smart_ptr/detail/spinlock.hpp>
\r
34 template< int I > class spinlock_pool
\r
38 static spinlock pool_[ 41 ];
\r
42 static spinlock & spinlock_for( void const * pv )
\r
44 std::size_t i = reinterpret_cast< std::size_t >( pv ) % 41;
\r
54 scoped_lock( scoped_lock const & );
\r
55 scoped_lock & operator=( scoped_lock const & );
\r
59 explicit scoped_lock( void const * pv ): sp_( spinlock_for( pv ) )
\r
71 template< int I > spinlock spinlock_pool< I >::pool_[ 41 ] =
\r
73 BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT,
\r
74 BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT,
\r
75 BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT,
\r
76 BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT,
\r
77 BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT,
\r
78 BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT,
\r
79 BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT,
\r
80 BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT,
\r
81 BOOST_DETAIL_SPINLOCK_INIT
\r
84 } // namespace detail
\r
85 } // namespace boost
\r
87 #endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_POOL_HPP_INCLUDED
\r