1 // Copyright (C) 2012 Vicente J. Botet Escriba
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)
6 // <boost/thread/lock_factories.hpp>
8 // template <class Mutex>
9 // unique_lock<Mutex> make_unique_lock(Mutex&);
11 #define BOOST_THREAD_VERSION 4
13 #include <boost/thread/lock_factories.hpp>
14 #include <boost/thread/mutex.hpp>
15 #include <boost/thread/thread.hpp>
16 #include <boost/detail/lightweight_test.hpp>
17 #include "../../../../../timming.hpp"
19 #if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && ! defined BOOST_THREAD_NO_MAKE_UNIQUE_LOCKS && ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
26 #if defined BOOST_THREAD_USES_CHRONO
28 typedef boost::chrono::high_resolution_clock Clock
;
29 typedef Clock::time_point time_point
;
30 typedef Clock::duration duration
;
31 typedef boost::chrono::milliseconds ms
;
32 typedef boost::chrono::nanoseconds ns
;
38 const ms
max_diff(BOOST_THREAD_TEST_TIME_MS
);
42 #if defined BOOST_THREAD_USES_CHRONO
45 auto&& _
= boost::make_unique_locks(m1
,m2
,m3
); (void)_
;
49 //time_point t0 = Clock::now();
52 auto&& _
= boost::make_unique_locks(m1
,m2
,m3
); (void)_
;
55 //ns d = t1 - t0 - ms(250);
56 //BOOST_TEST(d < max_diff);
66 #if defined BOOST_THREAD_USES_CHRONO
67 time_point t2
= Clock::now();
68 boost::this_thread::sleep_for(ms(250));
69 time_point t3
= Clock::now();
77 #if defined BOOST_THREAD_USES_CHRONO
78 ns sleep_time
= t3
- t2
;
79 ns d_ns
= t1
- t0
- sleep_time
;
80 ms d_ms
= boost::chrono::duration_cast
<boost::chrono::milliseconds
>(d_ns
);
81 // BOOST_TEST_GE(d_ms.count(), 0);
82 BOOST_THREAD_TEST_IT(d_ms
, max_diff
);
83 BOOST_THREAD_TEST_IT(d_ns
, ns(max_diff
));
86 return boost::report_errors();
91 return boost::report_errors();