1 #ifndef BOOST_DETAIL_SPINLOCK_SYNC_HPP_INCLUDED
2 #define BOOST_DETAIL_SPINLOCK_SYNC_HPP_INCLUDED
4 // MS compatible compilers support #pragma once
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
11 // Copyright (c) 2008 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/detail/yield_k.hpp>
20 #if defined( __ia64__ ) && defined( __INTEL_COMPILER )
21 # include <ia64intrin.h>
40 int r = __sync_lock_test_and_set( &v_, 1 );
46 for( unsigned k = 0; !try_lock(); ++k )
48 boost::detail::yield( k );
54 __sync_lock_release( &v_ );
65 scoped_lock( scoped_lock const & );
66 scoped_lock & operator=( scoped_lock const & );
70 explicit scoped_lock( spinlock & sp ): sp_( sp )
85 #define BOOST_DETAIL_SPINLOCK_INIT {0}
87 #endif // #ifndef BOOST_DETAIL_SPINLOCK_SYNC_HPP_INCLUDED