| 24 | using stdexec::sync_wait; |
| 25 | |
| 26 | auto main() -> int |
| 27 | { |
| 28 | exec::static_thread_pool ctx{8}; |
| 29 | scheduler auto sch = ctx.get_scheduler(); // 1 |
| 30 | |
| 31 | sender auto begin = schedule(sch); // 2 |
| 32 | sender auto hi_again = then( // 3 |
| 33 | begin, // 3 |
| 34 | [] { // 3 |
| 35 | std::cout << "Hello world! Have an int.\n"; // 3 |
| 36 | return 13; // 3 |
| 37 | }); // 3 |
| 38 | |
| 39 | sender auto add_42 = then(hi_again, [](int arg) { return arg + 42; }); // 4 |
| 40 | auto [i] = sync_wait(std::move(add_42)).value(); // 5 |
| 41 | std::cout << "Result: " << i << std::endl; |
| 42 | |
| 43 | // Sync_wait provides a run_loop scheduler |
| 44 | std::tuple<run_loop::scheduler> t = sync_wait(get_scheduler()).value(); |
| 45 | (void) t; |
| 46 | |
| 47 | auto y = let_value(get_scheduler(), |
| 48 | [](auto sched) |
| 49 | { |
| 50 | return starts_on(sched, |
| 51 | then(just(), |
| 52 | [] |
| 53 | { |
| 54 | std::cout << "from run_loop\n"; |
| 55 | return 42; |
| 56 | })); |
| 57 | }); |
| 58 | sync_wait(std::move(y)); |
| 59 | |
| 60 | sync_wait(when_all(just(42), get_scheduler(), get_stop_token())); |
| 61 | } |
nothing calls this directly
no test coverage detected