]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/fiber/examples/future.cpp
7 #include <boost/fiber/all.hpp>
10 int fn( std::string
const& str
, int n
)
12 for ( int i
= 0; i
< n
; ++i
)
14 std::cout
<< i
<< ": " << str
<< std::endl
;
15 boost::this_fiber::yield();
23 boost::fibers::future
< int > fi(
25 std::bind( fn
, "abc", 5) ) );
27 std::cout
<< "fn() returned " << fi
.get() << std::endl
;
34 boost::fibers::fiber( start
).join();
35 std::cout
<< "done." << std::endl
;
39 catch ( std::exception
const& e
)
40 { std::cerr
<< "exception: " << e
.what() << std::endl
; }
42 { std::cerr
<< "unhandled exception" << std::endl
; }