]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/coroutine/example/symmetric/unwind.cpp
2 // Copyright Oliver Kowalke 2009.
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)
10 #include <boost/bind.hpp>
11 #include <boost/coroutine/all.hpp>
13 struct X
: private boost::noncopyable
15 X() { std::cout
<< "X()" << std::endl
; }
16 ~X() { std::cout
<< "~X()" << std::endl
; }
19 typedef boost::coroutines::symmetric_coroutine
< void > coro_t
;
21 coro_t::call_type
* c1
= 0;
22 coro_t::call_type
* c2
= 0;
24 void foo( coro_t::yield_type
& yield
)
27 std::cout
<< "foo() entered" << std::endl
;
30 std::cout
<< "foo() finished" << std::endl
;
33 void bar( coro_t::yield_type
& yield
)
35 std::cout
<< "bar() entered" << std::endl
;
37 std::cout
<< "bar() finished" << std::endl
;
40 int main( int argc
, char * argv
[])
42 coro_t::call_type
coro1( foo
);
43 coro_t::call_type
coro2( bar
);
47 std::cout
<< "Done" << std::endl
;