]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/thread/test/sync/futures/promise/set_value_at_thread_exit_void_pass.cpp
1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Copyright (C) 2011 Vicente J. Botet Escriba
12 // Distributed under the Boost Software License, Version 1.0. (See accompanying
13 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
15 // <boost/thread/future.hpp>
19 // void promise<void>::set_value_at_thread_exit();
21 #define BOOST_THREAD_VERSION 4
23 #include <boost/thread/future.hpp>
24 #include <boost/detail/lightweight_test.hpp>
28 boost::promise
<void> p
;
31 p
.set_value_at_thread_exit();
35 //void func2_mv(BOOST_THREAD_RV_REF(boost::promise<void>) p2)
36 void func2_mv(boost::promise
<void> p2
)
38 p2
.set_value_at_thread_exit();
42 void func2(boost::promise
<void> *p2
)
44 p2
->set_value_at_thread_exit();
51 boost::future
<void> f
= p
.get_future();
52 boost::thread(func
).detach();
57 catch(std::exception
& )
68 boost::promise
<void> p2
;
69 boost::future
<void> f
= p2
.get_future();
71 boost::thread(func
).detach();
76 catch(std::exception
& ex
)
78 std::cout
<< __FILE__
<< ":" << __LINE__
<< " " << ex
.what() << std::endl
;
88 boost::promise
<void> p2
;
89 boost::future
<void> f
= p2
.get_future();
90 #if defined BOOST_THREAD_PROVIDES_VARIADIC_THREAD
91 boost::thread(func2_mv
, boost::move(p2
)).detach();
93 boost::thread(func2
, &p2
).detach();
99 catch(std::exception
& ex
)
101 std::cout
<< __FILE__
<< ":" << __LINE__
<< " " << ex
.what() << std::endl
;
108 return boost::report_errors();