Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions include/beman/execution/detail/affine_on.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <concepts>
#include <type_traits>

#include <beman/execution/detail/suppress_push.hpp>

// ----------------------------------------------------------------------------

namespace beman::execution::detail {
Expand Down Expand Up @@ -63,6 +65,21 @@ struct affine_on_t : ::beman::execution::sender_adaptor_closure<affine_on_t> {
*/
auto operator()() const { return ::beman::execution::detail::sender_adaptor{*this}; }

template <typename Ev>
struct ao_env {
Ev ev_;
auto query(const ::beman::execution::get_stop_token_t&) const noexcept
-> ::beman::execution::never_stop_token {
return ::beman::execution::never_stop_token();
}
template <typename Q>
auto query(const Q& q) const noexcept -> decltype(q(this->ev_)) {
return q(this->ev_);
}
};
template <typename Ev>
ao_env(const Ev&) -> ao_env<Ev>;

/**
* @brief affine_on is implemented by transforming it into a use of schedule_from.
*
Expand All @@ -89,35 +106,33 @@ struct affine_on_t : ::beman::execution::sender_adaptor_closure<affine_on_t> {
::beman::execution::get_completion_signatures(
::beman::execution::schedule(::beman::execution::get_scheduler(env)),
::beman::execution::detail::join_env(
::beman::execution::env{::beman::execution::prop{::beman::execution::get_stop_token,
::beman::execution::never_stop_token{}}},
::beman::execution::env{::beman::execution::prop{
::beman::execution::get_stop_token, ::beman::execution::never_stop_token{}, {}}},
Copy link

Copilot AI Jan 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The third parameter {} is passed explicitly to the prop constructor even though the deduction guide provides a default value for the non_assignable parameter. If the default value works correctly, this explicit {} may be unnecessary. Consider removing it to simplify the code and rely on the default parameter, or add a comment explaining why the explicit parameter is required.

Suggested change
::beman::execution::get_stop_token, ::beman::execution::never_stop_token{}, {}}},
::beman::execution::get_stop_token, ::beman::execution::never_stop_token{}}},

Copilot uses AI. Check for mistakes.
env))
} -> ::std::same_as<::beman::execution::completion_signatures<::beman::execution::set_value_t()>>;
}
static auto transform_sender(Sender&& sender, const Env& env) {
static auto transform_sender(Sender&& sender, const Env& ev) {
[[maybe_unused]] auto& [tag, data, child] = sender;
using child_tag_t = ::beman::execution::tag_of_t<::std::remove_cvref_t<decltype(child)>>;

#if 0
if constexpr (requires(const child_tag_t& t) {
{
t.affine_on(::beman::execution::detail::forward_like<Sender>(child), env)
t.affine_on(::beman::execution::detail::forward_like<Sender>(child), ev)
} -> ::beman::execution::sender;
})
#else
if constexpr (::beman::execution::detail::nested_sender_has_affine_on<Sender, Env>)
#endif
{
Copy link

Copilot AI Jan 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a constexpr local variable t and then immediately using it to call affine_on is unusual. If this is a workaround for a clang issue, consider adding a comment explaining why this intermediate variable is necessary instead of directly using child_tag_t{}.affine_on(...) as was done previously.

Suggested change
{
{
// NOTE: Some compilers (e.g. certain Clang versions) have had issues
// when invoking affine_on on a temporary, i.e. child_tag_t{}.affine_on(...).
// Using a named constexpr instance here avoids those issues; do not
// simplify back to a temporary without re-validating compiler support.

Copilot uses AI. Check for mistakes.
return child_tag_t{}.affine_on(::beman::execution::detail::forward_like<Sender>(child), env);
constexpr child_tag_t t{};
return t.affine_on(::beman::execution::detail::forward_like<Sender>(child), ev);
} else {
return ::beman::execution::write_env(
::beman::execution::schedule_from(
::beman::execution::get_scheduler(env),
::beman::execution::write_env(::beman::execution::detail::forward_like<Sender>(child), env)),
::beman::execution::detail::join_env(
::beman::execution::env{::beman::execution::prop{::beman::execution::get_stop_token,
::beman::execution::never_stop_token{}}},
env));
::beman::execution::get_scheduler(ev),
::beman::execution::write_env(::beman::execution::detail::forward_like<Sender>(child), ev)),
ao_env(ev));
}
}
};
Expand All @@ -135,4 +150,6 @@ inline constexpr affine_on_t affine_on{};

// ----------------------------------------------------------------------------

#include <beman/execution/detail/suppress_pop.hpp>

#endif
2 changes: 1 addition & 1 deletion include/beman/execution/detail/prop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ template <typename Query, typename Value>
struct prop;

template <typename Query, typename Value>
prop(Query, Value) -> prop<Query, ::std::unwrap_reference_t<Value>>;
prop(Query, Value, ::beman::execution::detail::non_assignable = {}) -> prop<Query, ::std::unwrap_reference_t<Value>>;
Copy link

Copilot AI Jan 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deduction guide now requires passing an extra parameter (the non_assignable object with default value) that doesn't correspond to a user-provided value. While this may work around a clang issue, this creates an inconsistency where users of prop must now be aware of this implementation detail. Consider whether this is the intended workaround, as it exposes the internal non_assignable_ member in the public API of the deduction guide.

Copilot uses AI. Check for mistakes.
} // namespace beman::execution

template <typename V>
Expand Down