]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/coroutine/example/symmetric/simple.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / coroutine / example / symmetric / simple.cpp
1
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)
6
7 #include <cstdlib>
8 #include <iostream>
9
10 #include <boost/bind.hpp>
11 #include <boost/coroutine/all.hpp>
12
13 typedef boost::coroutines::symmetric_coroutine< void > coro_t;
14
15 coro_t::call_type * c1 = 0;
16 coro_t::call_type * c2 = 0;
17
18 void foo( coro_t::yield_type & yield)
19 {
20 std::cout << "foo1" << std::endl;
21 yield( * c2);
22 std::cout << "foo2" << std::endl;
23 yield( * c2);
24 std::cout << "foo3" << std::endl;
25 }
26
27 void bar( coro_t::yield_type & yield)
28 {
29 std::cout << "bar1" << std::endl;
30 yield( * c1);
31 std::cout << "bar2" << std::endl;
32 yield( * c1);
33 std::cout << "bar3" << std::endl;
34 }
35
36 int main( int argc, char * argv[])
37 {
38 coro_t::call_type coro1( foo);
39 coro_t::call_type coro2( bar);
40 c1 = & coro1;
41 c2 = & coro2;
42 coro1();
43 std::cout << "Done" << std::endl;
44
45 return EXIT_SUCCESS;
46 }