]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/fiber/examples/future.cpp
2 // Copyright Oliver Kowalke 2013.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
13 #include <boost/fiber/all.hpp>
16 int fn( std::string
const& str
, int n
)
18 for ( int i
= 0; i
< n
; ++i
)
20 std::cout
<< i
<< ": " << str
<< std::endl
;
21 boost::this_fiber::yield();
29 boost::fibers::future
< int > fi(
31 std::bind( fn
, "abc", 5) ) );
33 std::cout
<< "fn() returned " << fi
.get() << std::endl
;
40 boost::fibers::fiber( start
).join();
41 std::cout
<< "done." << std::endl
;
45 catch ( std::exception
const& e
)
46 { std::cerr
<< "exception: " << e
.what() << std::endl
; }
48 { std::cerr
<< "unhandled exception" << std::endl
; }