From 7cb82c85b0956d2bd29c0b9153aead0810de9260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dietmar=20K=C3=BChl?= Date: Fri, 3 Apr 2026 20:40:07 +0200 Subject: [PATCH 1/4] brought the implementation up to the latest version of task --- CMakeLists.txt | 18 +-------- examples/CMakeLists.txt | 4 +- examples/demo_algorithm.hpp | 37 +++++++++++-------- examples/demo_task.hpp | 4 ++ include/beman/net/detail/context_base.hpp | 2 +- include/beman/net/detail/execution.hpp | 2 +- include/beman/net/detail/into_expected.hpp | 2 +- include/beman/net/detail/io_context.hpp | 9 +---- .../beman/net/detail/io_context_scheduler.hpp | 8 +++- include/beman/net/detail/poll_context.hpp | 5 +-- .../beman/net/detail/repeat_effect_until.hpp | 4 ++ include/beman/net/detail/sender.hpp | 4 ++ 12 files changed, 51 insertions(+), 48 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b18c0d0..f7e4f8b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,27 +27,11 @@ endif() include(FetchContent) -FetchContent_Declare( - execution - # FETCHCONTENT_SOURCE_DIR_EXECUTION ${CMAKE_SOURCE_DIR}/../execution - GIT_REPOSITORY https://github.com/bemanproject/execution - GIT_TAG 66295d5 - SYSTEM - FIND_PACKAGE_ARGS - 0.2.0 - EXACT - NAMES - beman.execution - COMPONENTS - execution_headers -) -FetchContent_MakeAvailable(execution) - FetchContent_Declare( task # FETCHCONTENT_SOURCE_DIR_TASK ${CMAKE_SOURCE_DIR}/../task GIT_REPOSITORY https://github.com/bemanproject/task - GIT_TAG 9075137 + GIT_TAG 16a5916 FIND_PACKAGE_ARGS 0.2.0 EXACT NAMES beman.task COMPONENTS task_headers ) FetchContent_MakeAvailable(task) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 402ed96..3961058 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -23,7 +23,6 @@ endif() set(EXAMPLES http-warwick - taps client cppcon-2024 empty @@ -31,12 +30,13 @@ set(EXAMPLES milano http-munich server + taps task ) set(xEXAMPLES taps) foreach(EXAMPLE ${EXAMPLES}) - set(EXAMPLE_TARGET ${TARGET_PREFIX}.examples.${EXAMPLE}) + set(EXAMPLE_TARGET beman.net.examples.${EXAMPLE}) add_executable(${EXAMPLE_TARGET}) if(BEMAN_NET_WITH_URING) # XXX target_compile_definitions( ${EXAMPLE_TARGET} PRIVATE BEMAN_NET_USE_URING) diff --git a/examples/demo_algorithm.hpp b/examples/demo_algorithm.hpp index 96caf9d..0d41bca 100644 --- a/examples/demo_algorithm.hpp +++ b/examples/demo_algorithm.hpp @@ -183,11 +183,15 @@ struct demo::into_error_t::receiver { template struct demo::into_error_t::sender { using sender_concept = ex::sender_t; - template - auto get_completion_signatures(const Env& env) const { - return ::beman::execution::detail::meta::unique<::beman::execution::detail::meta::transform< - demo::detail::into_error_transform::template type, - decltype(ex::get_completion_signatures(::std::declval(), env))>>(); + template + static consteval auto get_completion_signatures() { + // static_assert(sizeof...(Env) <= 1u); + if constexpr (sizeof...(Env) <= 1) + return ::beman::execution::detail::meta::unique<::beman::execution::detail::meta::transform< + demo::detail::into_error_transform::template type, + decltype(ex::get_completion_signatures<::std::remove_cvref_t, Env...>())>>(); + else + return ex::completion_signatures<>{}; } template @@ -356,21 +360,24 @@ template struct demo::when_any_t::sender { ::beman::execution::detail::product_type<::std::remove_cvref_t...> sender; using sender_concept = ex::sender_t; - using completion_signatures = ::beman::execution::detail::meta::unique<::beman::execution::detail::meta::combine< - decltype(ex::get_completion_signatures(::std::declval(), ex::env<>{}))...>>; + template + static consteval auto get_completion_signatures() { + return ::beman::execution::detail::meta::unique< + ::beman::execution::detail::meta::combine())...>>(); + } template auto connect(Receiver&& receiver) && -> state< ::std::index_sequence_for, ::std::remove_cvref_t, - demo::detail::variant_from_list_t< - ex::detail::transform>>>, - demo::detail::variant_from_list_t< - ex::detail::filter>, + demo::detail::variant_from_list_t())>>>>, + demo::detail::variant_from_list_t())>>, Sender...> { return {::std::forward(receiver), ::std::move(this->sender)}; } diff --git a/examples/demo_task.hpp b/examples/demo_task.hpp index eb59d34..1d2bc92 100644 --- a/examples/demo_task.hpp +++ b/examples/demo_task.hpp @@ -224,6 +224,10 @@ struct task { ::beman::net::detail::ex::completion_signatures<::beman::net::detail::ex::set_error_t(::std::exception_ptr), ::beman::net::detail::ex::set_stopped_t(), typename task_completion<::std::decay_t>::type>; + template + static consteval auto get_completion_signatures() -> completion_signatures { + return {}; + } template auto connect(Receiver&& receiver) { diff --git a/include/beman/net/detail/context_base.hpp b/include/beman/net/detail/context_base.hpp index 395ee46..dbe308c 100644 --- a/include/beman/net/detail/context_base.hpp +++ b/include/beman/net/detail/context_base.hpp @@ -48,7 +48,7 @@ struct beman::net::detail::context_base { -> void = 0; virtual auto listen(::beman::net::detail::socket_id, int, ::std::error_code&) -> void = 0; - virtual auto run_one() -> ::std::size_t = 0; + virtual auto run_one() noexcept -> ::std::size_t = 0; virtual auto cancel(::beman::net::detail::io_base*, ::beman::net::detail::io_base*) -> void = 0; virtual auto schedule(::beman::net::detail::context_base::task*) -> void = 0; diff --git a/include/beman/net/detail/execution.hpp b/include/beman/net/detail/execution.hpp index b1b27eb..64d67e8 100644 --- a/include/beman/net/detail/execution.hpp +++ b/include/beman/net/detail/execution.hpp @@ -33,7 +33,7 @@ using ::beman::execution::value_types_of_t; using ::beman::execution::get_completion_scheduler; using ::beman::execution::get_completion_scheduler_t; using ::beman::execution::get_completion_signatures; -using ::beman::execution::get_completion_signatures_t; +//-dk:TODO using ::beman::execution::get_completion_signatures_t; using ::beman::execution::get_delegation_scheduler; using ::beman::execution::get_delegation_scheduler_t; using ::beman::execution::get_scheduler; diff --git a/include/beman/net/detail/into_expected.hpp b/include/beman/net/detail/into_expected.hpp index ea181a0..2b18983 100644 --- a/include/beman/net/detail/into_expected.hpp +++ b/include/beman/net/detail/into_expected.hpp @@ -107,7 +107,7 @@ struct into_expected_t : beman::execution::sender_adaptor_closure - auto get_completion_signatures(const Env&) const { + static consteval auto get_completion_signatures() { return beman::execution::completion_signatures), beman::execution::set_stopped_t()>(); } diff --git a/include/beman/net/detail/io_context.hpp b/include/beman/net/detail/io_context.hpp index 876079d..44f08ff 100644 --- a/include/beman/net/detail/io_context.hpp +++ b/include/beman/net/detail/io_context.hpp @@ -99,12 +99,7 @@ class beman::net::io_context { : _context(context), _receiver(::std::forward(receiver)) {} run_one_state(run_one_state&&) = delete; auto start() & noexcept -> void { - try { - ::beman::execution::set_value(::std::move(this->_receiver), this->_context->run_one()); - } catch (...) { - //-dk:TODO deal with exceptions in async_run_one - std::cout << "run_one_state exception caught\n"; - } + ::beman::execution::set_value(::std::move(this->_receiver), this->_context->run_one()); } }; @@ -132,7 +127,7 @@ class beman::net::io_context { [&last_count] { return last_count == 0; }); }); } - ::std::size_t run_one() { return this->d_context.run_one(); } + ::std::size_t run_one() noexcept { return this->d_context.run_one(); } ::std::size_t run() { ::std::size_t count{}; while (::std::size_t c = this->run_one()) { diff --git a/include/beman/net/detail/io_context_scheduler.hpp b/include/beman/net/detail/io_context_scheduler.hpp index fa92cc1..872c6f8 100644 --- a/include/beman/net/detail/io_context_scheduler.hpp +++ b/include/beman/net/detail/io_context_scheduler.hpp @@ -35,6 +35,13 @@ class beman::net::detail::io_context_scheduler { } }; struct sender { + using sender_concept = ::beman::execution::sender_t; + using completion_signatures = beman::execution::completion_signatures; + template + static consteval auto get_completion_signatures() -> completion_signatures { + return {}; + } + template struct state : ::beman::net::detail::context_base::task { using operation_state_concept = ::beman::net::detail::ex::operation_state_t; @@ -49,7 +56,6 @@ class beman::net::detail::io_context_scheduler { auto complete() -> void override { ::beman::net::detail::ex::set_value(::std::move(this->d_receiver)); } }; - using sender_concept = ::beman::net::detail::ex::sender_t; ::beman::net::detail::context_base* d_context; template diff --git a/include/beman/net/detail/poll_context.hpp b/include/beman/net/detail/poll_context.hpp index c13bd41..7576ac1 100644 --- a/include/beman/net/detail/poll_context.hpp +++ b/include/beman/net/detail/poll_context.hpp @@ -15,7 +15,6 @@ #include #include #include -#include // ---------------------------------------------------------------------------- @@ -116,7 +115,7 @@ struct beman::net::detail::poll_context final : ::beman::net::detail::context_ba auto to_milliseconds(auto duration) -> int { return int(::std::chrono::duration_cast<::std::chrono::milliseconds>(duration).count()); } - auto run_one() -> ::std::size_t override final { + auto run_one() noexcept -> ::std::size_t override final { auto now{::std::chrono::system_clock::now()}; if (0u < this->process_timeout(now) || 0 < this->process_task()) { return 1u; @@ -191,7 +190,7 @@ struct beman::net::detail::poll_context final : ::beman::net::detail::context_ba op->cancel(); cancel_op->cancel(); } else { - std::cerr << "ERROR: poll_context::cancel(): entity not cancelled!\n"; + std::terminate(); } } auto schedule(::beman::net::detail::context_base::task* tsk) -> void override { diff --git a/include/beman/net/detail/repeat_effect_until.hpp b/include/beman/net/detail/repeat_effect_until.hpp index f20455b..fae5719 100644 --- a/include/beman/net/detail/repeat_effect_until.hpp +++ b/include/beman/net/detail/repeat_effect_until.hpp @@ -78,6 +78,10 @@ struct repeat_effect_until_t : beman::execution::sender_adaptor_closure; + template + static constexpr auto get_completion_signatures() -> completion_signatures { + return {}; + } Upstream upstream; Body body; diff --git a/include/beman/net/detail/sender.hpp b/include/beman/net/detail/sender.hpp index 648e052..ae54ec6 100644 --- a/include/beman/net/detail/sender.hpp +++ b/include/beman/net/detail/sender.hpp @@ -138,6 +138,10 @@ struct beman::net::detail::sender { ::beman::net::detail::ex::completion_signatures; + template + static consteval auto get_completion_signatures() -> completion_signatures { + return {}; + } Data d_data; Upstream d_upstream; From 370fb8cdfd8cc22f97f01bbddc48b8f0c80e3910 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dietmar=20K=C3=BChl?= Date: Fri, 3 Apr 2026 20:44:07 +0200 Subject: [PATCH 2/4] fixed the default for building examples --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 073af83..f7e4f8b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ option( option( BEMAN_NET_BUILD_EXAMPLES "Enable building examples. Default: ON. Values: { ON, OFF }." - OFF #-dk:TODO ${PROJECT_IS_TOP_LEVEL} + ${PROJECT_IS_TOP_LEVEL} ) if(LINUX) From 5bf80ec0459aa08312b0d44ac9f152e069db3b97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dietmar=20K=C3=BChl?= Date: Sat, 4 Apr 2026 19:09:49 +0200 Subject: [PATCH 3/4] fixed a formatting error --- examples/demo_algorithm.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/demo_algorithm.hpp b/examples/demo_algorithm.hpp index 0d41bca..95369ef 100644 --- a/examples/demo_algorithm.hpp +++ b/examples/demo_algorithm.hpp @@ -359,7 +359,7 @@ struct demo::when_any_t::state<::std::index_sequence, Receiver, Value, Err template struct demo::when_any_t::sender { ::beman::execution::detail::product_type<::std::remove_cvref_t...> sender; - using sender_concept = ex::sender_t; + using sender_concept = ex::sender_t; template static consteval auto get_completion_signatures() { return ::beman::execution::detail::meta::unique< From dc0b554225a8bb3b790cf714b79a1c12a48c9ad1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dietmar=20K=C3=BChl?= Date: Sat, 4 Apr 2026 19:16:43 +0200 Subject: [PATCH 4/4] added noexcept to run_one overrides --- include/beman/net/detail/iocp_context.hpp | 2 +- include/beman/net/detail/poll_context.hpp | 7 ++++--- include/beman/net/detail/uring_context.hpp | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/beman/net/detail/iocp_context.hpp b/include/beman/net/detail/iocp_context.hpp index cbfcf37..33756de 100644 --- a/include/beman/net/detail/iocp_context.hpp +++ b/include/beman/net/detail/iocp_context.hpp @@ -230,7 +230,7 @@ struct iocp_context final : context_base { } } - auto run_one() -> ::std::size_t override { + auto run_one() noexcept -> ::std::size_t override { auto now = ::std::chrono::system_clock::now(); if (process_timeout(now) > 0 || process_task() > 0) { return 1u; diff --git a/include/beman/net/detail/poll_context.hpp b/include/beman/net/detail/poll_context.hpp index cdc8752..6f63e19 100644 --- a/include/beman/net/detail/poll_context.hpp +++ b/include/beman/net/detail/poll_context.hpp @@ -10,11 +10,12 @@ #include #include #include -#include +#include +#include +#include #include #include -#include -#include +#include // ---------------------------------------------------------------------------- diff --git a/include/beman/net/detail/uring_context.hpp b/include/beman/net/detail/uring_context.hpp index 66e99fa..d7b7991 100644 --- a/include/beman/net/detail/uring_context.hpp +++ b/include/beman/net/detail/uring_context.hpp @@ -112,7 +112,7 @@ struct uring_context final : context_base { return {res, static_cast(completion)}; } - auto run_one() -> ::std::size_t override { + auto run_one() noexcept -> ::std::size_t override { if (auto count = process_task(); count) { return count; }