yo/coroutines/demo/recursive2/recursivecoro.cc
raw| 1 | #include "main.ih" |
| 2 | |
| 3 | //coro |
| 4 | Recursive recursiveCoro(size_t level) |
| 5 | { |
| 6 | while (true) |
| 7 | { |
| 8 | for (size_t idx = 0; idx != 2; ++idx) |
| 9 | co_yield g_fibo.next(); |
| 10 | |
| 11 | if (level < 5) |
| 12 | { |
| 13 | Recursive rec = recursiveCoro(level + 1); |
| 14 | size_t value; |
| 15 | while (rec.next(&value)) |
| 16 | co_yield value; |
| 17 | } |
| 18 | |
| 19 | for (size_t idx = 0; idx != 2; ++idx) |
| 20 | co_yield g_fibo.next(); |
| 21 | |
| 22 | if (level > 0) |
| 23 | break; |
| 24 | } |
| 25 | } |
| 26 | //= |