| 1 | #include <functional>
|
|---|
| 2 | #include <iostream>
|
|---|
| 3 | #include <boost/coroutine/all.hpp>
|
|---|
| 4 |
|
|---|
| 5 | using namespace std;
|
|---|
| 6 | using namespace std::placeholders;
|
|---|
| 7 | using namespace boost::coroutines;
|
|---|
| 8 |
|
|---|
| 9 | void 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 |
|
|---|
| 17 | int 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 | }
|
|---|