]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/thread/test/test_11256.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / thread / test / test_11256.cpp
1 // Copyright (C) 2015 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 #define BOOST_THREAD_VERSION 4
7 #define BOOST_THREAD_PROVIDES_EXECUTORS
8
9 #include <boost/thread.hpp>
10 #include <boost/thread/thread_pool.hpp>
11 #include <cassert>
12
13 auto createFuture()
14 {
15 boost::promise<void> promise;
16 promise.set_value();
17 return promise.get_future();
18 }
19
20 auto stepOne(boost::basic_thread_pool &executor)
21 {
22 auto sendFuture = createFuture();
23 auto wrappedFuture = sendFuture.then(executor, [](auto f) mutable {
24 return createFuture();
25 });
26
27 return wrappedFuture.unwrap();
28 }
29
30 auto stepTwo(boost::basic_thread_pool &executor)
31 {
32 auto future = stepOne(executor);
33 return future.then(executor, [](auto f) {
34 assert(f.is_ready());
35 });
36 }
37
38 int main()
39 {
40 boost::basic_thread_pool executor{1};
41 stepTwo(executor).get();
42 }