| 199 | } |
| 200 | |
| 201 | int recursive_fib(CoroContext<size_t>::Ptr ctx, size_t fib) |
| 202 | { |
| 203 | ctx->sleep(us(100)); |
| 204 | |
| 205 | if (fib <= 2) |
| 206 | { |
| 207 | return ctx->set(1); |
| 208 | } |
| 209 | else |
| 210 | { |
| 211 | //Post both branches of the Fibonacci series before blocking on get(). |
| 212 | auto ctx1 = ctx->post(recursive_fib, fib - 2); |
| 213 | auto ctx2 = ctx->post(recursive_fib, fib - 1); |
| 214 | return ctx->set(ctx1->get(ctx) + ctx2->get(ctx)); |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | void run_coro(Traits::Coroutine& coro, std::mutex& m, int& end, int start) |
| 219 | { |