| 47 | }; |
| 48 | |
| 49 | auto main() -> int |
| 50 | { |
| 51 | exec::static_thread_pool ctx{1}; |
| 52 | exec::async_scope scope; |
| 53 | |
| 54 | scheduler auto sch = ctx.get_scheduler(); // 1 |
| 55 | |
| 56 | sender auto begin = schedule(sch); // 2 |
| 57 | |
| 58 | sender auto printVoid = then(begin, []() noexcept { printf("void\n"); }); // 3 |
| 59 | |
| 60 | sender auto printEmpty = then( |
| 61 | starts_on(sch, scope.on_empty()), |
| 62 | []() noexcept { // 4 |
| 63 | printf("scope is empty\n"); |
| 64 | }); |
| 65 | |
| 66 | printf("\n" |
| 67 | "spawn void\n" |
| 68 | "==========\n"); |
| 69 | |
| 70 | scope.spawn(printVoid); // 5 |
| 71 | |
| 72 | sync_wait(printEmpty); |
| 73 | |
| 74 | printf("\n" |
| 75 | "spawn void and 42\n" |
| 76 | "=================\n"); |
| 77 | |
| 78 | sender auto fortyTwo = then(begin, []() noexcept { return 42; }); // 6 |
| 79 | |
| 80 | scope.spawn(printVoid); // 7 |
| 81 | |
| 82 | sender auto fortyTwoFuture = scope.spawn_future(fortyTwo); // 8 |
| 83 | |
| 84 | sender auto printFortyTwo = then( |
| 85 | std::move(fortyTwoFuture), |
| 86 | [](int fortyTwo) noexcept { // 9 |
| 87 | printf("%d\n", fortyTwo); |
| 88 | }); |
| 89 | |
| 90 | sender auto allDone = then(when_all(printEmpty, std::move(printFortyTwo)), |
| 91 | [](auto&&...) noexcept { printf("\nall done\n"); }); // 10 |
| 92 | |
| 93 | sync_wait(std::move(allDone)); |
| 94 | |
| 95 | { |
| 96 | sender auto nest = scope.nest(begin); |
| 97 | (void) nest; |
| 98 | } |
| 99 | sync_wait(scope.on_empty()); |
| 100 | |
| 101 | { |
| 102 | sender auto nest = scope.nest(begin); |
| 103 | auto op = connect(std::move(nest), noop_receiver{}); |
| 104 | (void) op; |
| 105 | } |
| 106 | sync_wait(scope.on_empty()); |
nothing calls this directly
no test coverage detected