1 // Copyright (C) 2014 Ian Forbed
2 // Copyright (C) 2014 Vicente J. Botet Escriba
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 #include <boost/config.hpp>
9 #if ! defined BOOST_NO_CXX11_DECLTYPE
10 #define BOOST_RESULT_OF_USE_DECLTYPE
13 #define BOOST_THREAD_VERSION 4
14 #define BOOST_THREAD_PROVIDES_EXECUTORS
16 #include <boost/function.hpp>
17 #include <boost/thread/executors/executor.hpp>
18 #include <boost/thread/executors/basic_thread_pool.hpp>
19 #include <boost/thread/executors/scheduling_adaptor.hpp>
20 #include <boost/chrono/chrono_io.hpp>
22 #include <boost/core/lightweight_test.hpp>
24 using namespace boost::chrono
;
27 typedef boost::executors::basic_thread_pool thread_pool
;
31 //std::cout << "[" << __LINE__ << "] " << steady_clock::now() << std::endl;
32 std::cout
<< x
<< std::endl
;
35 void test_timing(const int n
)
38 boost::scheduling_adaptor
<thread_pool
> sa(tp
);
39 for(int i
= 1; i
<= n
; i
++)
41 sa
.submit_after(boost::bind(fn
,i
),seconds(i
));
42 sa
.submit_after(boost::bind(fn
,i
), milliseconds(i
*100));
44 boost::this_thread::sleep_for(boost::chrono::seconds(10));
49 steady_clock::time_point start
= steady_clock::now();
51 steady_clock::duration diff
= steady_clock::now() - start
;
52 BOOST_TEST(diff
> seconds(5));
53 return boost::report_errors();