]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/thread/test/test_9079_a.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / thread / test / test_9079_a.cpp
1 // Copyright (C) 2013 Vicente Botet
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 // A
7
8 //#include <boost/log/trivial.hpp>
9 #include <boost/chrono.hpp>
10 #include <boost/thread.hpp>
11 #include <boost/thread/condition_variable.hpp>
12
13 //#if !defined(BOOST_NO_CXX11_ALIGNAS)
14 //#error
15 //# define BOOST_ALIGNMENT2(x) alignas(x)
16 //#elif defined(_MSC_VER)
17 //#error
18 //# define BOOST_ALIGNMENT2(x) __declspec(align(x))
19 //#elif defined(__GNUC__)
20 //#error
21 //# define BOOST_ALIGNMENT(x) __attribute__ ((__aligned__(x)))
22 //#else
23 //#error
24 //# define BOOST_NO_ALIGNMENT2
25 //# define BOOST_ALIGNMENT2(x)
26 //#endif
27
28 typedef boost::chrono::high_resolution_clock Clock;
29 typedef Clock::time_point TimePoint;
30
31 inline TimePoint real_time_now()
32 {
33 return Clock::now();
34 }
35
36 int main()
37 {
38 using namespace boost::chrono;
39
40 boost::condition_variable m_task_spawn_condition;
41
42 boost::mutex main_thread_mutex;
43 boost::unique_lock < boost::mutex > main_thread_lock(main_thread_mutex);
44
45 //BOOST_LOG_TRIVIAL(info) << "[TaskScheduler::run_and_wait] Scheduling loop - BEGIN";
46
47 //for (;;)
48 {
49 static const milliseconds TIME_BACK = milliseconds(1);
50 m_task_spawn_condition.wait_until(
51 main_thread_lock,
52 real_time_now() - TIME_BACK); // wait forever
53 m_task_spawn_condition.wait_for( main_thread_lock, - TIME_BACK ); // same problem
54 //BOOST_LOG_TRIVIAL(trace) << "TICK";
55 }
56
57 }