File indexing completed on 2025-01-18 09:30:26
0001
0002 #ifndef BOOST_CONTRACT_DETAIL_CHECKING_HPP_
0003 #define BOOST_CONTRACT_DETAIL_CHECKING_HPP_
0004
0005
0006
0007
0008
0009
0010 #include <boost/contract/core/config.hpp>
0011 #include <boost/contract/detail/static_local_var.hpp>
0012 #include <boost/contract/detail/declspec.hpp>
0013 #include <boost/thread/mutex.hpp>
0014 #include <boost/noncopyable.hpp>
0015 #include <boost/config.hpp>
0016
0017 namespace boost { namespace contract { namespace detail {
0018
0019 #ifdef BOOST_MSVC
0020 #pragma warning(push)
0021 #pragma warning(disable: 4275)
0022 #pragma warning(disable: 4251)
0023 #endif
0024
0025
0026 class BOOST_CONTRACT_DETAIL_DECLSPEC checking :
0027 private boost::noncopyable
0028 {
0029 public:
0030 explicit checking() {
0031 #ifndef BOOST_CONTRACT_DISABLE_THREADS
0032 init_locked();
0033 #else
0034 init_unlocked();
0035 #endif
0036 }
0037
0038 ~checking() {
0039 #ifndef BOOST_CONTRACT_DISABLE_THREADS
0040 done_locked();
0041 #else
0042 done_unlocked();
0043 #endif
0044 }
0045
0046 static bool already() {
0047 #ifndef BOOST_CONTRACT_DISABLE_THREADS
0048 return already_locked();
0049 #else
0050 return already_unlocked();
0051 #endif
0052 }
0053
0054 private:
0055 void init_unlocked();
0056 void init_locked();
0057
0058 void done_unlocked();
0059 void done_locked();
0060
0061 static bool already_unlocked();
0062 static bool already_locked();
0063
0064 struct mutex_tag;
0065 typedef static_local_var<mutex_tag, boost::mutex> mutex;
0066
0067 struct checking_tag;
0068 typedef static_local_var_init<checking_tag, bool, bool, false> flag;
0069 };
0070
0071 #ifdef BOOST_MSVC
0072 #pragma warning(pop)
0073 #endif
0074
0075 } } }
0076
0077 #ifdef BOOST_CONTRACT_HEADER_ONLY
0078 #include <boost/contract/detail/inlined/detail/checking.hpp>
0079 #endif
0080
0081 #endif
0082