From 11b2c88058f6df66b7249008f733dd6311b4b705 Mon Sep 17 00:00:00 2001 From: JorgeV92 Date: Tue, 5 May 2026 14:48:23 -0500 Subject: [PATCH 01/17] sub_visit.hpp added --- include/beman/execution/detail/sub_visit.hpp | 44 ++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 include/beman/execution/detail/sub_visit.hpp diff --git a/include/beman/execution/detail/sub_visit.hpp b/include/beman/execution/detail/sub_visit.hpp new file mode 100644 index 00000000..a527bfd4 --- /dev/null +++ b/include/beman/execution/detail/sub_visit.hpp @@ -0,0 +1,44 @@ +// include/beman/execution/detail/sub_visit.hpp -*-C++-*- +// ---------------------------------------------------------------------------- +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// ---------------------------------------------------------------------------- + +#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_SUB_VISIT +#define INCLUDED_BEMAN_EXECUTION_DETAIL_SUB_VISIT + +#include +#include +#include + +// ---------------------------------------------------------------------------- + +namespace beman::execution::detail { +/* + * \brief Helper function creatig thunks for a variant visit. + * \headerfile beman/execution/task.hpp + * \internal + */ +template +void sub_visit_thunks(Fun& fun, Var& var, std::index_sequence) { + using thunk_t = void (*)(Fun&, Var&); + static constexpr thunk_t thunks[]{(+[](Fun& f, Var& v) { f(std::get(v)); })...}; + thunks[var.index() - Start](fun, var); +} + +/* + * \brief Helper function visiting a suffix of variant options + * \headerfile beman/execution/task.hpp + * \internal + */ +template +void sub_visit(auto&& fun, std::variant& v) { + if (v.index() < Start) + return; + sub_visit_thunks(fun, v, std::make_index_sequence{}); +} + +} // namespace beman::execution::detail + +// ---------------------------------------------------------------------------- + +#endif \ No newline at end of file From 5940a2692c012be16e2773f33e464f5ab742d377 Mon Sep 17 00:00:00 2001 From: JorgeV92 Date: Tue, 5 May 2026 15:45:35 -0500 Subject: [PATCH 02/17] fix new line --- include/beman/execution/detail/sub_visit.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/beman/execution/detail/sub_visit.hpp b/include/beman/execution/detail/sub_visit.hpp index a527bfd4..19b9cb59 100644 --- a/include/beman/execution/detail/sub_visit.hpp +++ b/include/beman/execution/detail/sub_visit.hpp @@ -41,4 +41,4 @@ void sub_visit(auto&& fun, std::variant& v) { // ---------------------------------------------------------------------------- -#endif \ No newline at end of file +#endif From c4fb5a060e7fc93f9f6129855ea6b0ec2b13930d Mon Sep 17 00:00:00 2001 From: JorgeV92 Date: Wed, 13 May 2026 15:30:36 -0500 Subject: [PATCH 03/17] added poly.hpp from beamn.task --- include/beman/execution/detail/poly.hpp | 79 +++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 include/beman/execution/detail/poly.hpp diff --git a/include/beman/execution/detail/poly.hpp b/include/beman/execution/detail/poly.hpp new file mode 100644 index 00000000..33358bd5 --- /dev/null +++ b/include/beman/execution/detail/poly.hpp @@ -0,0 +1,79 @@ +// include/beman/execution/detail/poly.hpp -*-C++-*- +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_POLY +#define INCLUDED_BEMAN_EXECUTION_DETAIL_POLY + +#include +#include +#include +#include +#include + +// ---------------------------------------------------------------------------- + +namespace beman::execution::detail { +/*! + * \brief Utility providing small object optimization and type erasure. + * \headerfile beman/execution/task.hpp + * \internal + */ +template +class alignas(sizeof(double)) poly { + private: + std::array buf{}; + + Base* pointer() { return static_cast(static_cast(buf.data())); } + const Base* pointer() const { return static_cast(static_cast(buf.data())); } + + public: + template + requires(sizeof(T) <= Size) + poly(T*, Args&&... args) { + new (this->buf.data()) T(::std::forward(args)...); + static_assert(sizeof(T) <= Size); + } + poly(poly&& other) + requires requires(Base* b, void* t) { b->move(t); } + { + other.pointer()->move(this->buf.data()); + } + poly& operator=(poly&& other) + requires requires(Base* b, void* t) { b->move(t); } + { + if (this != &other) { + this->pointer()->~Base(); + other.pointer()->move(this->buf.data()); + } + return *this; + } + poly& operator=(const poly& other) + requires requires(Base* b, void* t) { b->clone(t); } + { + if (this != &other) { + this->pointer()->~Base(); + other.pointer()->clone(this->buf.data()); + } + return *this; + } + poly(const poly& other) + requires requires(Base* b, void* t) { b->clone(t); } + { + other.pointer()->clone(this->buf.data()); + } + ~poly() { this->pointer()->~Base(); } + bool operator==(const poly& other) const + requires requires(const Base& b) { + { b.equals(&b) } -> std::same_as; + } + { + return other.pointer()->equals(this->pointer()); + } + Base* operator->() { return this->pointer(); } + const Base* operator->() const { return this->pointer(); } +}; +} // namespace beman::execution::detail + +// ---------------------------------------------------------------------------- + +#endif From e6fe9e14d9bcd4e7ab451c80f6b12a96193fe9c4 Mon Sep 17 00:00:00 2001 From: JorgeV92 Date: Wed, 13 May 2026 16:15:40 -0500 Subject: [PATCH 04/17] added with_error.hpp from beman.task --- include/beman/execution/detail/with_error.hpp | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 include/beman/execution/detail/with_error.hpp diff --git a/include/beman/execution/detail/with_error.hpp b/include/beman/execution/detail/with_error.hpp new file mode 100644 index 00000000..7ad12ccb --- /dev/null +++ b/include/beman/execution/detail/with_error.hpp @@ -0,0 +1,30 @@ +// include/beman/execution/detail/with_error.hpp -*-C++-*- +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_WITH_ERROR +#define INCLUDED_BEMAN_EXECUTION_DETAIL_WITH_ERROR + +#include +#include +#include + +// ---------------------------------------------------------------------------- +/* + * \brief Tag type used to indicate an error is produced. + * \headerfile beman/execution/task.hpp + * \internal + */ +namespace beman::execution::detail { +template +struct with_error { + using type = ::std::remove_cvref_t; + type error; +}; +template +with_error(E&&) -> with_error; + +} // namespace beman::execution::detail + +// ---------------------------------------------------------------------------- + +#endif \ No newline at end of file From 9333803b4654656f8f6dd4153e8cbfd19f97a428 Mon Sep 17 00:00:00 2001 From: JorgeV92 Date: Wed, 13 May 2026 16:44:32 -0500 Subject: [PATCH 05/17] added allocator_of.hpp from beman.task --- .../beman/execution/detail/allocator_of.hpp | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 include/beman/execution/detail/allocator_of.hpp diff --git a/include/beman/execution/detail/allocator_of.hpp b/include/beman/execution/detail/allocator_of.hpp new file mode 100644 index 00000000..b3e7effb --- /dev/null +++ b/include/beman/execution/detail/allocator_of.hpp @@ -0,0 +1,39 @@ +// include/beman/execution/detail/allocator_of.hpp -*-C++-*- +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_ALLOCATOR_OF +#define INCLUDED_BEMAN_EXECUTION_DETAIL_ALLOCATOR_OF + +#include +#include +#include + +// ---------------------------------------------------------------------------- + +namespace beman::execution::detail { +/*! + * \brief Utility to get an allocator type from a context + * \headerfile beman/execution/task.hpp + * \internal + */ +template +struct allocator_of { + using type = std::allocator; +}; +template + requires requires { typename Context::allocator_type; } +struct allocator_of { + using type = typename Context::allocator_type; + static_assert( + requires(type& a, std::size_t s, std::byte* ptr) { + { a.allocate(s) } -> std::same_as; + a.deallocate(ptr, s); + }, "The allocator_type needs to be an allocator of std::byte"); +}; +template +using allocator_of_t = typename allocator_of::type; +} // namespace beman::execution::detail + +// ---------------------------------------------------------------------------- + +#endif \ No newline at end of file From 1738d5f42fc5865b4cabd14fbbd8b756826c7726 Mon Sep 17 00:00:00 2001 From: JorgeV92 Date: Wed, 13 May 2026 16:59:24 -0500 Subject: [PATCH 06/17] added find_allocator.hpp from beman.task --- .../beman/execution/detail/find_allocator.hpp | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 include/beman/execution/detail/find_allocator.hpp diff --git a/include/beman/execution/detail/find_allocator.hpp b/include/beman/execution/detail/find_allocator.hpp new file mode 100644 index 00000000..dca559e9 --- /dev/null +++ b/include/beman/execution/detail/find_allocator.hpp @@ -0,0 +1,47 @@ +// include/beman/execution/detail/find_allocator.hpp -*-C++-*- +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_FIND_ALLOCATOR +#define INCLUDED_BEMAN_EXECUTION_DETAIL_FIND_ALLOCATOR + +#include +#include + +// ---------------------------------------------------------------------------- + +namespace beman::execution::detail { +/*! + * \brief Utility locating an allocator_arg/allocator pair + * \headerfile beman/execution/task.hpp + * \internal + */ +template +Allocator find_allocator() { + return Allocator(); +} +template +Allocator find_allocator(const std::allocator_arg_t&) { + static_assert( + requires { + { Allocator() } -> std::same_as; + }, "There needs to be an allocator argument following std::allocator_arg"); + return Allocator(); +} + +template +Allocator find_allocator(const std::allocator_arg_t&, const Alloc& alloc, const A&...) { + static_assert( + requires(const Alloc& a) { Allocator(a); }, + "The allocator needs to be constructible from the argument following std::allocator"); + return Allocator(alloc); +} +template +Allocator find_allocator(A0 const&, const A&... a) { + return ::beman::execution::detail::find_allocator(a...); +} + +} // namespace beman::execution::detail + +// ---------------------------------------------------------------------------- + +#endif \ No newline at end of file From fa6a840050c58e43faaecebb1f4005005801c745 Mon Sep 17 00:00:00 2001 From: JorgeV92 Date: Wed, 13 May 2026 17:20:57 -0500 Subject: [PATCH 07/17] added completion.hpp from beman.task --- include/beman/execution/detail/completion.hpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 include/beman/execution/detail/completion.hpp diff --git a/include/beman/execution/detail/completion.hpp b/include/beman/execution/detail/completion.hpp new file mode 100644 index 00000000..27270a5c --- /dev/null +++ b/include/beman/execution/detail/completion.hpp @@ -0,0 +1,28 @@ +// include/beman/execution/detail/completion.hpp -*-C++-*- +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_COMPLETION +#define INCLUDED_BEMAN_EXECUTION_DETAIL_COMPLETION + +#include + +// ---------------------------------------------------------------------------- + +namespace beman::execution::detail { +template +struct completion { + using type = ::beman::execution::set_value_t(R); +}; +template <> +struct completion { + using type = ::beman::execution::set_value_t(); +}; + +template +using completion_t = typename beman::execution::detail::completion::type; + +} // namespace beman::execution::detail + +// ---------------------------------------------------------------------------- + +#endif \ No newline at end of file From ac49d57760dc085b45e5c523db6075aaa121933c Mon Sep 17 00:00:00 2001 From: JorgeV92 Date: Wed, 13 May 2026 17:37:47 -0500 Subject: [PATCH 08/17] added error_types_of.hpp --- .../beman/execution/detail/error_types_of.hpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 include/beman/execution/detail/error_types_of.hpp diff --git a/include/beman/execution/detail/error_types_of.hpp b/include/beman/execution/detail/error_types_of.hpp new file mode 100644 index 00000000..ea130048 --- /dev/null +++ b/include/beman/execution/detail/error_types_of.hpp @@ -0,0 +1,28 @@ +// include/beman/execution/detail/error_types_of.hpp -*-C++-*- +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_CONTEXT_ERROR_TYPES_OF +#define INCLUDED_BEMAN_EXECUTION_DETAIL_CONTEXT_ERROR_TYPES_OF + +#include +#include + +// ---------------------------------------------------------------------------- + +namespace beman::execution::detail { +template +struct error_types_of { + using type = ::beman::execution::completion_signatures<::beman::execution::set_error_t(::std::exception_ptr)>; +}; +template + requires requires { typename Context::error_types; } +struct error_types_of { + using type = typename Context::error_types; +}; +template +using error_types_of_t = typename error_types_of::type; +} // namespace beman::execution::detail + +// ---------------------------------------------------------------------------- + +#endif // INCLUDED_BEMAN_EXECUTION_DETAIL_CONTEXT_ERROR_TYPES_OF From f614e776081dfaf1fac9c5ade310037eb9768d4c Mon Sep 17 00:00:00 2001 From: JorgeV92 Date: Wed, 13 May 2026 17:59:10 -0500 Subject: [PATCH 09/17] added stop_source_of.hpp --- .../beman/execution/detail/stop_source_of.hpp | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 include/beman/execution/detail/stop_source_of.hpp diff --git a/include/beman/execution/detail/stop_source_of.hpp b/include/beman/execution/detail/stop_source_of.hpp new file mode 100644 index 00000000..85d6e25e --- /dev/null +++ b/include/beman/execution/detail/stop_source_of.hpp @@ -0,0 +1,27 @@ +// include/beman/execution/detail/stop_source_of.hpp -*-C++-*- +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_STOP_SOURCE_OF +#define INCLUDED_BEMAN_EXECUTION_DETAIL_STOP_SOURCE_OF + +#include + +// ---------------------------------------------------------------------------- + +namespace beman::execution::detail { +template +struct stop_source_of { + using type = ::beman::execution::inplace_stop_source; +}; +template + requires requires { typename Context::stop_source_type; } +struct stop_source_of { + using type = typename Context::stop_source_type; +}; +template +using stop_source_of_t = typename stop_source_of::type; +} // namespace beman::execution::detail + +// ---------------------------------------------------------------------------- + +#endif // INCLUDED_BEMAN_EXECUTION_DETAIL_STOP_SOURCE_OF From 48f2e421719010dbdf46f346733e50bbb81e0fa9 Mon Sep 17 00:00:00 2001 From: JorgeV92 Date: Wed, 13 May 2026 19:18:54 -0500 Subject: [PATCH 10/17] update CMakeLists --- src/beman/execution/CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/beman/execution/CMakeLists.txt b/src/beman/execution/CMakeLists.txt index 674d52c5..10634d92 100644 --- a/src/beman/execution/CMakeLists.txt +++ b/src/beman/execution/CMakeLists.txt @@ -25,6 +25,7 @@ target_sources( FILES ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/affine_on.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/allocator_aware_move.hpp + ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/allocator_of.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/almost_scheduler.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/apply_sender.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/as_awaitable.hpp @@ -46,6 +47,7 @@ target_sources( ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/child_type.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/class_type.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/common.hpp + ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/completion.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/completion_domain.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/completion_signature.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/completion_signatures.hpp @@ -76,7 +78,9 @@ target_sources( ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/env_of_t.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/env_promise.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/env_type.hpp + ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/error_types_of.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/error_types_of_t.hpp + ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/find_allocator.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/forward_like.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/forwarding_query.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/fwd_env.hpp @@ -134,6 +138,7 @@ target_sources( ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/operation_state.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/operation_state_task.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/product_type.hpp + ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/poly.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/prop.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/query_with_default.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/queryable.hpp @@ -175,6 +180,7 @@ target_sources( ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/state_type.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/stop_callback_for_t.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/stop_source.hpp + ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/stop_source_of.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/stop_token_of_t.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/stop_when.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/stoppable_source.hpp @@ -182,6 +188,7 @@ target_sources( ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/stopped_as_error.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/stopped_as_optional.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/store_receiver.hpp + ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/sub_visit.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/suppress_pop.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/suppress_push.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/suspend_complete.hpp @@ -203,6 +210,7 @@ target_sources( ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/when_all_with_variant.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/with_await_transform.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/with_awaitable_senders.hpp + ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/with_error.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/write_env.hpp ) From 8ac9a7c3f02be179f2292f6cadf58f15e8e536ed Mon Sep 17 00:00:00 2001 From: JorgeV92 Date: Wed, 13 May 2026 19:33:03 -0500 Subject: [PATCH 11/17] added handle.hpp --- include/beman/execution/detail/handle.hpp | 49 +++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 include/beman/execution/detail/handle.hpp diff --git a/include/beman/execution/detail/handle.hpp b/include/beman/execution/detail/handle.hpp new file mode 100644 index 00000000..60d8ce5b --- /dev/null +++ b/include/beman/execution/detail/handle.hpp @@ -0,0 +1,49 @@ +// include/beman/execution/detail/handle.hpp -*-C++-*- +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_HANDLE +#define INCLUDED_BEMAN_EXECUTION_DETAIL_HANDLE + +#include +#include +#include +#include +#include + +// ---------------------------------------------------------------------------- + +namespace beman::execution::detail { +template +class handle { + private: + struct deleter { + auto operator()(P* p) noexcept -> void { + if (p) { + std::coroutine_handle

::from_promise(*p).destroy(); + } + } + }; + std::unique_ptr h; + + public: + explicit handle(P* p) : h(p) {} + auto reset() -> void { this->h.reset(); } + template + auto start(A&&... a) noexcept -> auto { + return this->h->start(::std::forward(a)...); + } + auto release() -> ::std::coroutine_handle

{ + return ::std::coroutine_handle

::from_promise(*this->h.release()); + } + P* get() const noexcept { return this->h.get(); } + auto get_env() const noexcept { + assert(this->h.get()); + return ::beman::execution::get_env(*this->h); + } +}; + +} // namespace beman::execution::detail + +// ---------------------------------------------------------------------------- + +#endif From 696f31954f9ee25cbebb3ee0a9f737484aad5cb6 Mon Sep 17 00:00:00 2001 From: JorgeV92 Date: Wed, 13 May 2026 19:35:56 -0500 Subject: [PATCH 12/17] updated CMakeLists --- src/beman/execution/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/beman/execution/CMakeLists.txt b/src/beman/execution/CMakeLists.txt index 10634d92..4e894a82 100644 --- a/src/beman/execution/CMakeLists.txt +++ b/src/beman/execution/CMakeLists.txt @@ -98,6 +98,7 @@ target_sources( ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/get_forward_progress_guarantee.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/get_scheduler.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/get_stop_token.hpp + ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/handle.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/has_as_awaitable.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/has_completions.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/immovable.hpp From 44d2878e8573909991b2c5a48bfafc6eafd378b3 Mon Sep 17 00:00:00 2001 From: JorgeV92 Date: Wed, 13 May 2026 19:39:10 -0500 Subject: [PATCH 13/17] added state_rep.hpp --- include/beman/execution/detail/state_rep.hpp | 49 ++++++++++++++++++++ src/beman/execution/CMakeLists.txt | 1 + 2 files changed, 50 insertions(+) create mode 100644 include/beman/execution/detail/state_rep.hpp diff --git a/include/beman/execution/detail/state_rep.hpp b/include/beman/execution/detail/state_rep.hpp new file mode 100644 index 00000000..8d369924 --- /dev/null +++ b/include/beman/execution/detail/state_rep.hpp @@ -0,0 +1,49 @@ +// include/beman/execution/detail/state_rep.hpp -*-C++-*- +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_STATE_REP +#define INCLUDED_BEMAN_EXECUTION_DETAIL_STATE_REP + +#include +#include +#include + +// ---------------------------------------------------------------------------- + +namespace beman::execution::detail { +template +struct state_rep { + std::remove_cvref_t receiver; + C context; + template + state_rep(R&& r) : receiver(std::forward(r)), context() {} +}; +template + requires requires { C(::beman::execution::get_env(std::declval&>())); } && + (not requires(const Receiver& receiver) { + typename C::template env_type; + }) +struct state_rep { + std::remove_cvref_t receiver; + C context; + template + state_rep(R&& r) : receiver(std::forward(r)), context(::beman::execution::get_env(this->receiver)) {} +}; +template + requires requires(const Receiver& receiver) { + typename C::template env_type; + } +struct state_rep { + using upstream_env = decltype(::beman::execution::get_env(std::declval&>())); + std::remove_cvref_t receiver; + typename C::template env_type own_env; + C context; + template + state_rep(R&& r) + : receiver(std::forward(r)), own_env(::beman::execution::get_env(this->receiver)), context(this->own_env) {} +}; +} // namespace beman::execution::detail + +// ---------------------------------------------------------------------------- + +#endif diff --git a/src/beman/execution/CMakeLists.txt b/src/beman/execution/CMakeLists.txt index 4e894a82..6b62ec61 100644 --- a/src/beman/execution/CMakeLists.txt +++ b/src/beman/execution/CMakeLists.txt @@ -178,6 +178,7 @@ target_sources( ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/spawn_get_allocator.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/start.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/starts_on.hpp + ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/state_rep.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/state_type.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/stop_callback_for_t.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/stop_source.hpp From e75383ba5834f49c0eb3f5bce09882eafdc0e4b3 Mon Sep 17 00:00:00 2001 From: JorgeV92 Date: Wed, 13 May 2026 19:43:43 -0500 Subject: [PATCH 14/17] added promise_env.hpp --- .../beman/execution/detail/promise_env.hpp | 40 +++++++++++++++++++ src/beman/execution/CMakeLists.txt | 1 + 2 files changed, 41 insertions(+) create mode 100644 include/beman/execution/detail/promise_env.hpp diff --git a/include/beman/execution/detail/promise_env.hpp b/include/beman/execution/detail/promise_env.hpp new file mode 100644 index 00000000..503e7c64 --- /dev/null +++ b/include/beman/execution/detail/promise_env.hpp @@ -0,0 +1,40 @@ +// include/beman/execution/detail/promise_env.hpp -*-C++-*- +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_PROMISE_ENV +#define INCLUDED_BEMAN_EXECUTION_DETAIL_PROMISE_ENV + +#include +#include + +// ---------------------------------------------------------------------------- + +namespace beman::execution::detail { +template +struct promise_env { + const Promise* promise; + + auto query(const ::beman::execution::get_scheduler_t&) const noexcept -> typename Promise::scheduler_type { + return this->promise->get_scheduler(); + } + auto query(const ::beman::execution::get_allocator_t&) const noexcept -> typename Promise::allocator_type { + return this->promise->get_allocator(); + } + auto query(const ::beman::execution::get_stop_token_t&) const noexcept -> typename Promise::stop_token_type { + return this->promise->get_stop_token(); + } + + template + requires requires(const Promise* p, Q q, A&&... a) { + ::beman::execution::forwarding_query(q); + q(p->get_environment(), std::forward(a)...); + } + auto query(Q q, A&&... a) const noexcept { + return q(promise->get_environment(), std::forward(a)...); + } +}; +} // namespace beman::execution::detail + +// ---------------------------------------------------------------------------- + +#endif \ No newline at end of file diff --git a/src/beman/execution/CMakeLists.txt b/src/beman/execution/CMakeLists.txt index 6b62ec61..925056cc 100644 --- a/src/beman/execution/CMakeLists.txt +++ b/src/beman/execution/CMakeLists.txt @@ -140,6 +140,7 @@ target_sources( ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/operation_state_task.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/product_type.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/poly.hpp + ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/promise_env.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/prop.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/query_with_default.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/queryable.hpp From 108814c32d9f41798a4543c64527c47df88d65cb Mon Sep 17 00:00:00 2001 From: JorgeV92 Date: Wed, 13 May 2026 19:46:01 -0500 Subject: [PATCH 15/17] added logger.hpp --- include/beman/execution/detail/logger.hpp | 40 +++++++++++++++++++++++ src/beman/execution/CMakeLists.txt | 1 + 2 files changed, 41 insertions(+) create mode 100644 include/beman/execution/detail/logger.hpp diff --git a/include/beman/execution/detail/logger.hpp b/include/beman/execution/detail/logger.hpp new file mode 100644 index 00000000..11d3a17c --- /dev/null +++ b/include/beman/execution/detail/logger.hpp @@ -0,0 +1,40 @@ +// include/beman/execution/detail/logger.hpp -*-C++-*- +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_LOGGER +#define INCLUDED_BEMAN_EXECUTION_DETAIL_LOGGER + +#include +#include +#include + +// ---------------------------------------------------------------------------- + +namespace beman::execution::detail { +struct logger { + static auto level(int i) -> int { + static int rc{}; + return rc += i; + } + ::std::ostream& log(const char* pre, const char* msg) { + ::std::fill_n(::std::ostreambuf_iterator(std::cout.rdbuf()), level(0), ' '); + std::cout << pre; + return std::cout << msg << "\n"; + } + ::std::ostream& log(const char* msg) { return log("| ", msg); } + const char* msg; + explicit logger(const char* m) : msg(m) { + level(1); + log("\\ ", this->msg); + } + logger(logger&&) = delete; + ~logger() { + log("/ ", this->msg); + level(-1); + } +}; +} // namespace beman::execution::detail + +// ---------------------------------------------------------------------------- + +#endif \ No newline at end of file diff --git a/src/beman/execution/CMakeLists.txt b/src/beman/execution/CMakeLists.txt index 925056cc..94a6320d 100644 --- a/src/beman/execution/CMakeLists.txt +++ b/src/beman/execution/CMakeLists.txt @@ -115,6 +115,7 @@ target_sources( ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/join_env.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/just.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/let.hpp + ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/logger.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/make_env.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/make_sender.hpp ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/matching_sig.hpp From bd22106891e39a3e35e1929c4197f91e1d69a846 Mon Sep 17 00:00:00 2001 From: JorgeV92 Date: Wed, 13 May 2026 20:18:02 -0500 Subject: [PATCH 16/17] add end of line --- include/beman/execution/detail/completion.hpp | 2 +- include/beman/execution/detail/find_allocator.hpp | 2 +- include/beman/execution/detail/logger.hpp | 2 +- include/beman/execution/detail/promise_env.hpp | 2 +- include/beman/execution/detail/with_error.hpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/beman/execution/detail/completion.hpp b/include/beman/execution/detail/completion.hpp index 27270a5c..75d82ebf 100644 --- a/include/beman/execution/detail/completion.hpp +++ b/include/beman/execution/detail/completion.hpp @@ -25,4 +25,4 @@ using completion_t = typename beman::execution::detail::completion::type; // ---------------------------------------------------------------------------- -#endif \ No newline at end of file +#endif diff --git a/include/beman/execution/detail/find_allocator.hpp b/include/beman/execution/detail/find_allocator.hpp index dca559e9..8ace784d 100644 --- a/include/beman/execution/detail/find_allocator.hpp +++ b/include/beman/execution/detail/find_allocator.hpp @@ -44,4 +44,4 @@ Allocator find_allocator(A0 const&, const A&... a) { // ---------------------------------------------------------------------------- -#endif \ No newline at end of file +#endif diff --git a/include/beman/execution/detail/logger.hpp b/include/beman/execution/detail/logger.hpp index 11d3a17c..4fea369e 100644 --- a/include/beman/execution/detail/logger.hpp +++ b/include/beman/execution/detail/logger.hpp @@ -37,4 +37,4 @@ struct logger { // ---------------------------------------------------------------------------- -#endif \ No newline at end of file +#endif diff --git a/include/beman/execution/detail/promise_env.hpp b/include/beman/execution/detail/promise_env.hpp index 503e7c64..9560a0e9 100644 --- a/include/beman/execution/detail/promise_env.hpp +++ b/include/beman/execution/detail/promise_env.hpp @@ -37,4 +37,4 @@ struct promise_env { // ---------------------------------------------------------------------------- -#endif \ No newline at end of file +#endif diff --git a/include/beman/execution/detail/with_error.hpp b/include/beman/execution/detail/with_error.hpp index 7ad12ccb..c6bf423f 100644 --- a/include/beman/execution/detail/with_error.hpp +++ b/include/beman/execution/detail/with_error.hpp @@ -27,4 +27,4 @@ with_error(E&&) -> with_error; // ---------------------------------------------------------------------------- -#endif \ No newline at end of file +#endif From 0f9ac044ee37efca074d00c644e657f81ab26ef3 Mon Sep 17 00:00:00 2001 From: JorgeV92 Date: Wed, 13 May 2026 20:30:19 -0500 Subject: [PATCH 17/17] newline added --- include/beman/execution/detail/allocator_of.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/beman/execution/detail/allocator_of.hpp b/include/beman/execution/detail/allocator_of.hpp index b3e7effb..4e6d9010 100644 --- a/include/beman/execution/detail/allocator_of.hpp +++ b/include/beman/execution/detail/allocator_of.hpp @@ -36,4 +36,4 @@ using allocator_of_t = typename allocator_of::type; // ---------------------------------------------------------------------------- -#endif \ No newline at end of file +#endif