]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/thread/example/default_executor.cpp
1 // Copyright (C) 2014 Vicente Botet
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 #include <boost/config.hpp>
7 #if ! defined BOOST_NO_CXX11_DECLTYPE
8 #define BOOST_RESULT_OF_USE_DECLTYPE
11 #define BOOST_THREAD_VERSION 4
12 #define BOOST_THREAD_PROVIDES_EXECUTORS
13 //#define BOOST_THREAD_USES_LOG
14 #define BOOST_THREAD_USES_LOG_THREAD_ID
15 #define BOOST_THREAD_QUEUE_DEPRECATE_OLD
17 #include <boost/thread/caller_context.hpp>
18 #include <boost/thread/executors/basic_thread_pool.hpp>
19 #include <boost/thread/executors/generic_executor_ref.hpp>
23 #include <boost/thread/caller_context.hpp>
26 boost::generic_executor_ref
default_executor()
28 static boost::basic_thread_pool
tp(4);
29 return boost::generic_executor_ref(tp
);
34 std::cout
<< BOOST_CONTEXTOF
<< std::endl
;
35 boost::this_thread::sleep_for(boost::chrono::milliseconds(200));
36 std::cout
<< BOOST_CONTEXTOF
<< std::endl
;
42 std::cout
<< BOOST_CONTEXTOF
<< std::endl
;
43 boost::this_thread::sleep_for(boost::chrono::milliseconds(200));
44 default_executor().submit(&p2
);
45 boost::this_thread::sleep_for(boost::chrono::milliseconds(400));
46 std::cout
<< BOOST_CONTEXTOF
<< std::endl
;
51 std::cout
<< BOOST_CONTEXTOF
<< std::endl
;
53 default_executor().submit(&p1
);
55 boost::this_thread::sleep_for(boost::chrono::seconds(5));
57 std::cout
<< BOOST_CONTEXTOF
<< std::endl
;