spinlock_test.cpp 644 B

12345678910111213141516171819202122232425262728293031
  1. //
  2. // spinlock_test.cpp
  3. //
  4. // Copyright 2008 Peter Dimov
  5. //
  6. // Distributed under the Boost Software License, Version 1.0.
  7. // See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #include <boost/smart_ptr/detail/spinlock.hpp>
  11. // Sanity check only
  12. static boost::detail::spinlock sp = BOOST_DETAIL_SPINLOCK_INIT;
  13. static boost::detail::spinlock sp2 = BOOST_DETAIL_SPINLOCK_INIT;
  14. int main()
  15. {
  16. sp.lock();
  17. sp2.lock();
  18. sp.unlock();
  19. sp2.unlock();
  20. {
  21. boost::detail::spinlock::scoped_lock lock( sp );
  22. boost::detail::spinlock::scoped_lock lock2( sp2 );
  23. }
  24. return 0;
  25. }