spinlock.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_HPP_INCLUDED
  2. #define BOOST_SMART_PTR_DETAIL_SPINLOCK_HPP_INCLUDED
  3. // MS compatible compilers support #pragma once
  4. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  5. # pragma once
  6. #endif
  7. //
  8. // boost/detail/spinlock.hpp
  9. //
  10. // Copyright (c) 2008 Peter Dimov
  11. //
  12. // Distributed under the Boost Software License, Version 1.0.
  13. // See accompanying file LICENSE_1_0.txt or copy at
  14. // http://www.boost.org/LICENSE_1_0.txt)
  15. //
  16. // struct spinlock
  17. // {
  18. // void lock();
  19. // bool try_lock();
  20. // void unlock();
  21. //
  22. // class scoped_lock;
  23. // };
  24. //
  25. // #define BOOST_DETAIL_SPINLOCK_INIT <unspecified>
  26. //
  27. #include <boost/config.hpp>
  28. #include <boost/smart_ptr/detail/sp_has_sync.hpp>
  29. #if defined( BOOST_SP_USE_STD_ATOMIC )
  30. # if !defined( __clang__ )
  31. # include <boost/smart_ptr/detail/spinlock_std_atomic.hpp>
  32. # else
  33. // Clang (at least up to 3.4) can't compile spinlock_pool when
  34. // using std::atomic, so substitute the __sync implementation instead.
  35. # include <boost/smart_ptr/detail/spinlock_sync.hpp>
  36. # endif
  37. #elif defined( BOOST_SP_USE_PTHREADS )
  38. # include <boost/smart_ptr/detail/spinlock_pt.hpp>
  39. #elif !defined( BOOST_NO_CXX11_HDR_ATOMIC )
  40. # include <boost/smart_ptr/detail/spinlock_std_atomic.hpp>
  41. #elif defined(__GNUC__) && defined( __arm__ ) && !defined( __thumb__ )
  42. # include <boost/smart_ptr/detail/spinlock_gcc_arm.hpp>
  43. #elif defined( BOOST_SP_HAS_SYNC )
  44. # include <boost/smart_ptr/detail/spinlock_sync.hpp>
  45. #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
  46. # include <boost/smart_ptr/detail/spinlock_w32.hpp>
  47. #elif defined(BOOST_HAS_PTHREADS)
  48. # include <boost/smart_ptr/detail/spinlock_pt.hpp>
  49. #elif !defined(BOOST_HAS_THREADS)
  50. # include <boost/smart_ptr/detail/spinlock_nt.hpp>
  51. #else
  52. # error Unrecognized threading platform
  53. #endif
  54. #endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_HPP_INCLUDED