]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/thread/test/test_11818.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
7 #include <boost/config.hpp>
8 #if ! defined BOOST_NO_CXX11_DECLTYPE
9 #define BOOST_RESULT_OF_USE_DECLTYPE
12 #include <boost/thread/future.hpp>
13 #include <boost/thread/thread.hpp>
20 boost::promise
<int> promise
;
21 boost::future
<int> future
= promise
.get_future();
23 boost::future
<int> result
=
26 boost::launch::deferred
,
27 [](boost::future
<int> && f
)
29 std::cout
<< std::this_thread::get_id() << ": callback" << std::endl
;
30 std::cout
<< "The value is: " << f
.get() << std::endl
;
35 // We could not reach here.
36 std::cout
<< std::this_thread::get_id() << ": function" << std::endl
;
42 boost::promise
<int> promise
;
43 boost::shared_future
<int> future
= promise
.get_future().share();
45 boost::future
<int> result
=
48 boost::launch::deferred
,
49 [](boost::shared_future
<int> && f
)
51 std::cout
<< std::this_thread::get_id() << ": callback" << std::endl
;
52 std::cout
<< "The value is: " << f
.get() << std::endl
;
57 // We could not reach here.
58 std::cout
<< std::this_thread::get_id() << ": function" << std::endl
;