1 // Copyright (C) 2012 Vicente J. Botet Escriba 2 // 3 // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6 // <boost/thread/locks.hpp> 7 8 // template <class Mutex> class strict_lock; 9 10 // bool owns_lock(Mutex *) const; 11 12 #include <boost/thread/strict_lock.hpp> 13 #include <boost/thread/mutex.hpp> 14 #include <boost/thread/thread.hpp> 15 #include <boost/detail/lightweight_test.hpp> 16 17 #ifdef BOOST_THREAD_USES_CHRONO 18 typedef boost::chrono::high_resolution_clock Clock; 19 typedef Clock::time_point time_point; 20 typedef Clock::duration duration; 21 typedef boost::chrono::milliseconds ms; 22 typedef boost::chrono::nanoseconds ns; 23 #endif 24 main()25int main() 26 { 27 boost::mutex m; 28 boost::mutex m2; 29 30 boost::strict_lock<boost::mutex> lk(m); 31 BOOST_TEST(lk.owns_lock(&m) == true); 32 BOOST_TEST(!lk.owns_lock(&m2) == true); 33 return boost::report_errors(); 34 } 35