]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/thread/test/test_12293.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
8 // BoostFutureTest.cpp : Defines the entry point for the console application.
13 // boost version 1.60.0
14 // has the following set.
15 #define BOOST_THREAD_VERSION 4
16 // #define BOOST_THREAD_PROVIDES_EXECUTORS
18 #include <boost/thread/future.hpp>
25 boost::promise
<void> promise1
;
26 boost::promise
<void> promise2
;
28 auto future1
= promise1
.get_future();
30 auto waitFuture
= future1
.then([&tmpValue
, &promise2
](boost::future
<void> future
){
31 assert(future
.is_ready()); // this works correctly and is ready.
33 auto fut
= boost::async(boost::launch::async
, [&promise2
, &tmpValue
](){
34 boost::this_thread::sleep_for(boost::chrono::seconds(1));
37 std::cout
<< "Step 2 "<< std::endl
; // should print 1 but prints 0
39 std::cout
<< "Step 1 "<< std::endl
; // should print 1 but prints 0
41 return promise2
.get_future();
43 }).then([&value
, &tmpValue
](boost::future
<boost::future
<void>> future
){
44 //}).then([&value, &tmpValue](boost::future<void> future){
45 // error: no matching function for call to ‘boost::future<boost::future<void> >::then(main()::<lambda(boost::future<void>)>)’
48 assert(future
.is_ready()); // this doesn't work correctly and is not ready.
58 std::cout
<< "value = " << value
<< std::endl
; // should print 1 but prints 0