diff --git a/include/beman/task/detail/handle.hpp b/include/beman/task/detail/handle.hpp index 276bdfe..b1d9471 100644 --- a/include/beman/task/detail/handle.hpp +++ b/include/beman/task/detail/handle.hpp @@ -15,11 +15,13 @@ namespace beman::task::detail { template class handle { private: - using deleter = decltype([](auto p) { - if (p) { - std::coroutine_handle

::from_promise(*p).destroy(); + struct deleter { + auto operator()(P* p) noexcept -> void { + if (p) { + std::coroutine_handle

::from_promise(*p).destroy(); + } } - }); + }; std::unique_ptr h; public: diff --git a/include/beman/task/detail/into_optional.hpp b/include/beman/task/detail/into_optional.hpp index e57055a..04488aa 100644 --- a/include/beman/task/detail/into_optional.hpp +++ b/include/beman/task/detail/into_optional.hpp @@ -48,7 +48,7 @@ inline constexpr struct into_optional_t : beman::execution::sender_adaptor_closu } template - auto get_type(Env&&) const { + static auto get_type(Env&&) { return find_type( ::beman::execution::value_types_of_t, type_list, type_list>()); } @@ -69,18 +69,21 @@ inline constexpr struct into_optional_t : beman::execution::sender_adaptor_closu type_list<::beman::execution::set_stopped_t()>, type_list<>>{}); } - + template + struct make_object { + template + auto + operator()(A&&... a) const -> decltype(get_type(::beman::execution::get_env(std::declval()))) { + if constexpr (sizeof...(A) == 0u) + return {}; + else + return {std::forward(a)...}; + } + }; template auto connect(Receiver&& receiver) && { return ::beman::execution::connect( - ::beman::execution::then( - std::move(this->upstream), - [](A&&... a) -> decltype(get_type(::beman::execution::get_env(receiver))) { - if constexpr (sizeof...(A) == 0u) - return {}; - else - return {std::forward(a)...}; - }), + ::beman::execution::then(std::move(this->upstream), make_object{}), std::forward(receiver)); } }; diff --git a/include/beman/task/detail/single_thread_context.hpp b/include/beman/task/detail/single_thread_context.hpp index 541f7f8..f6b0aea 100644 --- a/include/beman/task/detail/single_thread_context.hpp +++ b/include/beman/task/detail/single_thread_context.hpp @@ -5,6 +5,7 @@ #define INCLUDED_INCLUDE_BEMAN_TASK_DETAIL_SINGLE_THREAD_CONTEXT #include +#include #include // ---------------------------------------------------------------------------- @@ -13,7 +14,9 @@ namespace beman::task::detail { class single_thread_context { private: ::beman::execution::run_loop loop; - ::std::thread thread{[this] { this->loop.run(); }}; + ::std::thread thread{&single_thread_context::run, this}; + + static auto run(single_thread_context* self) -> void { self->loop.run(); } public: single_thread_context() = default;