checking.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef BOOST_CONTRACT_DETAIL_INLINED_DETAIL_CHECKING_HPP_
  2. #define BOOST_CONTRACT_DETAIL_INLINED_DETAIL_CHECKING_HPP_
  3. // Copyright (C) 2008-2018 Lorenzo Caminiti
  4. // Distributed under the Boost Software License, Version 1.0 (see accompanying
  5. // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
  6. // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
  7. // IMPORTANT: Do NOT use config macros BOOST_CONTRACT_... in this file so lib
  8. // .cpp does not need recompiling if config changes (recompile only user code).
  9. #include <boost/contract/detail/checking.hpp>
  10. #include <boost/contract/detail/declspec.hpp>
  11. #include <boost/thread/lock_guard.hpp>
  12. namespace boost { namespace contract { namespace detail {
  13. BOOST_CONTRACT_DETAIL_DECLINLINE
  14. void checking::init_unlocked() { flag::ref() = true; }
  15. BOOST_CONTRACT_DETAIL_DECLINLINE
  16. void checking::init_locked() {
  17. boost::lock_guard<boost::mutex> lock(mutex::ref());
  18. init_unlocked();
  19. }
  20. BOOST_CONTRACT_DETAIL_DECLINLINE
  21. void checking::done_unlocked() { flag::ref() = false; }
  22. BOOST_CONTRACT_DETAIL_DECLINLINE
  23. void checking::done_locked() {
  24. boost::lock_guard<boost::mutex> lock(mutex::ref());
  25. done_unlocked();
  26. }
  27. BOOST_CONTRACT_DETAIL_DECLINLINE
  28. bool checking::already_unlocked() { return flag::ref(); }
  29. BOOST_CONTRACT_DETAIL_DECLINLINE
  30. bool checking::already_locked() {
  31. boost::lock_guard<boost::mutex> lock(mutex::ref());
  32. return already_unlocked();
  33. }
  34. } } } // namespace
  35. #endif