Ticket #9151: coro.cc

File coro.cc, 576 bytes (added by extproxy@…, 9 years ago)

coro.cc

Line 
1#include <functional>
2#include <iostream>
3#include <boost/coroutine/all.hpp>
4
5using namespace std;
6using namespace std::placeholders;
7using namespace boost::coroutines;
8
9void Hello(coroutine<void(int)>::caller_type& ca) {
10 cout << "In Hello " << ca.get() << endl;
11 ca();
12 cout << "In Hello end " << ca.get() << endl;
13 ca();
14 cout << "In Hello end " << ca.get() << endl;
15}
16
17int main(int argc, char **argv) {
18 coroutine<void(int)> coro(Hello, 6);
19
20 cout << "In Main1" << endl;
21 int x = 4;
22 while (coro) {
23 coro(x++);
24 }
25 cout << "In Main2" << endl;
26
27 return 0;
28}