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