]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/thread/test/test_11611.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 #define BOOST_THREAD_VERSION 4
10 #define BOOST_THREAD_PROVIDES_FUTURE
11 #define BOOST_THREAD_PROVIDES_EXECUTORS
12 #define BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
14 #if __cplusplus >= 201103L
15 #include <boost/thread/executors/loop_executor.hpp>
16 #include <boost/thread/executors/serial_executor.hpp>
18 #include <boost/thread/thread.hpp>
19 #include <boost/atomic.hpp>
25 #if __cplusplus >= 201103L
26 static std::size_t const nWorks
= 100000;
27 boost::atomic
<unsigned> execCount(0u);
28 boost::loop_executor ex
;
30 boost::thread
t([&ex
]()
36 boost::serial_executor
serial(ex
);
38 for (size_t i
= 0; i
< nWorks
; i
++)
39 serial
.submit([i
, &execCount
] {
40 //std::cout << i << ".";
46 unsigned const cnt
= execCount
.load();
48 // Since the serial_executor is closed, all work should have been done,
49 // even though the loop_executor ex is not.
50 std::cerr
<< "Only " << cnt
<< " of " << nWorks
<< " works executed!\n";
54 if (ex
.try_executing_one()) {
56 << "loop_executor::try_executing_one suceeded on closed executor!\n";
63 std::cout
<< "end\n" << std::endl
;