]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/fiber/examples/simple.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/intrusive_ptr.hpp>
15 #include <boost/fiber/all.hpp>
18 void fn( std::string
const& str
, int n
) {
19 for ( int i
= 0; i
< n
; ++i
) {
20 std::cout
<< i
<< ": " << str
<< std::endl
;
21 boost::this_fiber::yield();
27 boost::fibers::fiber
f1( fn
, "abc", 5);
28 std::cerr
<< "f1 : " << f1
.get_id() << std::endl
;
30 std::cout
<< "done." << std::endl
;
33 } catch ( std::exception
const& e
) {
34 std::cerr
<< "exception: " << e
.what() << std::endl
;
36 std::cerr
<< "unhandled exception" << std::endl
;