]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_locks_mutex_pass.cpp
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>
18 #if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && ! defined BOOST_THREAD_NO_MAKE_UNIQUE_LOCKS && ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
25 #if defined BOOST_THREAD_USES_CHRONO
27 typedef boost::chrono::system_clock Clock
;
28 typedef Clock::time_point time_point
;
29 typedef Clock::duration duration
;
30 typedef boost::chrono::milliseconds ms
;
31 typedef boost::chrono::nanoseconds ns
;
35 #ifdef BOOST_THREAD_PLATFORM_WIN32
36 const ms
max_diff(250);
38 const ms
max_diff(75);
43 #if defined BOOST_THREAD_USES_CHRONO
44 time_point t0
= Clock::now();
47 auto&& _
= boost::make_unique_locks(m1
,m2
,m3
); (void)_
;
50 ns d
= t1
- t0
- ms(250);
51 BOOST_TEST(d
< max_diff
);
53 //time_point t0 = Clock::now();
56 auto&& _
= boost::make_unique_locks(m1
,m2
,m3
); (void)_
;
59 //ns d = t1 - t0 - ms(250);
60 //BOOST_TEST(d < max_diff);
70 #if defined BOOST_THREAD_USES_CHRONO
71 boost::this_thread::sleep_for(ms(250));
79 return boost::report_errors();
84 return boost::report_errors();