1 #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_STD_ATOMIC_HPP_INCLUDED
2 #define BOOST_SMART_PTR_DETAIL_SPINLOCK_STD_ATOMIC_HPP_INCLUDED
4 // MS compatible compilers support #pragma once
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
11 // Copyright (c) 2014 Peter Dimov
13 // Distributed under the Boost Software License, Version 1.0.
14 // See accompanying file LICENSE_1_0.txt or copy at
15 // http://www.boost.org/LICENSE_1_0.txt)
18 #include <boost/smart_ptr/detail/yield_k.hpp>
37 return !v_.test_and_set( std::memory_order_acquire );
42 for( unsigned k = 0; !try_lock(); ++k )
44 boost::detail::yield( k );
50 v_ .clear( std::memory_order_release );
61 scoped_lock( scoped_lock const & );
62 scoped_lock & operator=( scoped_lock const & );
66 explicit scoped_lock( spinlock & sp ): sp_( sp )
81 #define BOOST_DETAIL_SPINLOCK_INIT { ATOMIC_FLAG_INIT }
83 #endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_STD_ATOMIC_HPP_INCLUDED