Skip to content

Commit bb55e02

Browse files
authored
Fix inline_scheduler (#319)
1 parent 6197b80 commit bb55e02

3 files changed

Lines changed: 31 additions & 4 deletions

File tree

‎include/beman/execution/detail/continues_on.hpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ struct continues_on_t {
136136
::beman::execution::detail::fwd_env(env)...);
137137
}
138138
auto query(::beman::execution::get_completion_scheduler_t<Tag>, const Env&... env) const noexcept {
139-
return ::beman::execution::get_completion_scheduler<Tag>(this->sch, env...);
139+
return ::beman::execution::get_completion_scheduler<Tag>(this->sch,
140+
::beman::execution::detail::fwd_env(env)...);
140141
}
141142

142143
template <typename Tag, typename... Env>

‎include/beman/execution/detail/inline_scheduler.hpp‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import std;
1515
#ifdef BEMAN_HAS_MODULES
1616
import beman.execution.detail.completion_signatures;
1717
import beman.execution.detail.get_forward_progress_guarantee;
18+
import beman.execution.detail.get_completion_domain;
19+
import beman.execution.detail.get_completion_scheduler;
20+
import beman.execution.detail.get_domain;
1821
import beman.execution.detail.get_scheduler;
1922
import beman.execution.detail.inline_attrs;
2023
import beman.execution.detail.operation_state;
@@ -25,6 +28,9 @@ import beman.execution.detail.sender;
2528
import beman.execution.detail.set_value;
2629
#else
2730
#include <beman/execution/detail/completion_signatures.hpp>
31+
#include <beman/execution/detail/get_completion_domain.hpp>
32+
#include <beman/execution/detail/get_completion_scheduler.hpp>
33+
#include <beman/execution/detail/get_domain.hpp>
2834
#include <beman/execution/detail/get_forward_progress_guarantee.hpp>
2935
#include <beman/execution/detail/get_scheduler.hpp>
3036
#include <beman/execution/detail/inline_attrs.hpp>
@@ -42,10 +48,25 @@ struct inline_scheduler {
4248

4349
using env = ::beman::execution::detail::inline_attrs<::beman::execution::set_value_t>;
4450

45-
auto query(::beman::execution::get_forward_progress_guarantee_t) const noexcept
51+
static auto query(::beman::execution::get_forward_progress_guarantee_t) noexcept
4652
-> ::beman::execution::forward_progress_guarantee {
4753
return ::beman::execution::forward_progress_guarantee::weakly_parallel;
4854
}
55+
56+
template <typename Env>
57+
requires requires(const Env& env) { ::beman::execution::get_scheduler(env); }
58+
static auto query(const ::beman::execution::get_completion_scheduler_t<::beman::execution::set_value_t>&,
59+
const Env& env) noexcept {
60+
return ::beman::execution::get_scheduler(env);
61+
}
62+
63+
template <typename Env>
64+
requires requires(const Env& env) { ::beman::execution::get_domain(env); }
65+
static auto query(const ::beman::execution::get_completion_domain_t<::beman::execution::set_value_t>&,
66+
const Env& env) noexcept {
67+
return ::beman::execution::get_domain(env);
68+
}
69+
4970
template <::beman::execution::receiver Rcvr>
5071
struct state {
5172
using operation_state_concept = ::beman::execution::operation_state_tag;

‎tests/beman/execution/exec-inline-scheduler.test.cpp‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,12 @@ auto test_get_completion_scheduler_with_env() {
204204
auto query(test_std::get_scheduler_t) const noexcept { return custom_scheduler{7}; }
205205
};
206206

207-
auto sched = test_std::get_completion_scheduler<test_std::set_value_t>(attrs, test_env{});
207+
auto sched = test_std::get_completion_scheduler<test_std::set_value_t>(attrs, test_env{});
208+
auto sched1 = test_std::get_completion_scheduler<test_std::set_value_t>(test_std::inline_scheduler{}, test_env{});
208209
static_assert(std::same_as<decltype(sched), custom_scheduler>);
210+
static_assert(std::same_as<decltype(sched), decltype(sched1)>);
209211
ASSERT(sched == custom_scheduler{7});
212+
ASSERT(sched == sched1);
210213
}
211214

212215
auto test_get_completion_domain_with_env() {
@@ -217,8 +220,10 @@ auto test_get_completion_domain_with_env() {
217220
auto query(test_std::get_domain_t) const noexcept { return custom_domain{}; }
218221
};
219222

220-
auto dom = test_std::get_completion_domain<test_std::set_value_t>(attrs, test_env{});
223+
auto dom = test_std::get_completion_domain<test_std::set_value_t>(attrs, test_env{});
224+
auto dom1 = test_std::get_completion_domain<test_std::set_value_t>(test_std::inline_scheduler{}, test_env{});
221225
static_assert(std::same_as<decltype(dom), custom_domain>);
226+
static_assert(std::same_as<decltype(dom), decltype(dom1)>);
222227
}
223228

224229
} // namespace

0 commit comments

Comments
 (0)