| 80 | |
| 81 | template <std::invocable Fn> |
| 82 | ex::sender auto make_stop_callback(Fn&& fn) noexcept |
| 83 | { |
| 84 | return ex::read_env(ex::get_stop_token) |
| 85 | | ex::then( |
| 86 | [fn = std::forward<Fn>(fn)](auto token) mutable noexcept |
| 87 | { |
| 88 | using cb_t = decltype(token)::template callback_type<std::remove_cvref_t<Fn>>; |
| 89 | return std::optional<cb_t>(std::in_place, std::move(token), std::move(fn)); |
| 90 | }); |
| 91 | } |
| 92 | |
| 93 | TEST_CASE("callbacks registered with stop-when's token can be invoked", "[adaptors][stop-when]") |
| 94 | { |
no test coverage detected