Skip to content

Commit 5253d68

Browse files
Address Copilot feedback on split and tests
1 parent c0f2bb3 commit 5253d68

2 files changed

Lines changed: 21 additions & 12 deletions

File tree

libs/core/execution/include/hpx/execution/algorithms/split.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ namespace hpx::execution::experimental {
517517
friend void tag_invoke(
518518
set_stopped_t, schedule_receiver&& r) noexcept
519519
{
520-
r.holder.reset();
520+
auto h = HPX_MOVE(r.holder);
521521
}
522522

523523
friend empty_env tag_invoke(

libs/core/execution/tests/unit/algorithm_split_scheduler.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,25 @@ int hpx_main()
7070
}
7171

7272
// -----------------------------------------------------------------------
73-
// Test 2: split with thread_pool_scheduler via pipeline syntax.
73+
// Test 2: split with a custom scheduler using a scheduler-aware sender.
7474
//
75-
// The pipeline `sched | ex::split(just(100))` triggers
76-
// tag_override_invoke which reads get_completion_scheduler<set_value_t>
77-
// from the sender, and routes to our new generic-scheduler tag_invoke on
78-
// split_t. Late-arriving subscribers must get their completion on the
79-
// thread pool, not inline on this thread.
75+
// This test uses `ex::split(ex::transfer(ex::just(100), sched))`.
76+
// `ex::transfer` attaches `sched` as the completion scheduler of the
77+
// predecessor sender, and `ex::split` must preserve that scheduler when a
78+
// late subscriber connects after the predecessor has already completed.
79+
// Late-arriving subscribers must get their completion on the custom scheduler,
80+
// not inline on this thread.
8081
// -----------------------------------------------------------------------
8182
{
82-
ex::thread_pool_scheduler sched{};
83-
84-
// just(100) | transfer(sched) gives a sender whose completion
85-
// scheduler is sched, so split picks up the scheduler automatically.
83+
std::atomic<bool> schedule_called{false};
84+
std::atomic<bool> execute_called{false};
85+
std::atomic<bool> tag_invoke_overload_called{false};
86+
example_scheduler sched{
87+
schedule_called, execute_called, tag_invoke_overload_called};
88+
89+
// `ex::transfer(ex::just(100), sched)` gives a sender whose completion
90+
// scheduler is `sched`, so `ex::split` picks up the scheduler
91+
// automatically.
8692
auto shared_s = ex::split(ex::transfer(ex::just(100), sched));
8793

8894
std::atomic<int> call_count{0};
@@ -94,14 +100,17 @@ int hpx_main()
94100
}));
95101
HPX_TEST_EQ(call_count.load(), 1);
96102

103+
schedule_called = false;
104+
97105
// Second subscriber — predecessor_done is now true.
98106
// Before the fix: fires inline on THIS thread.
99-
// After the fix: dispatched through thread_pool_scheduler.
107+
// After the fix: dispatched through the custom scheduler.
100108
tt::sync_wait(ex::then(shared_s, [&](int v) {
101109
HPX_TEST_EQ(v, 100);
102110
++call_count;
103111
}));
104112
HPX_TEST_EQ(call_count.load(), 2);
113+
HPX_TEST(schedule_called.load());
105114
}
106115

107116
// -----------------------------------------------------------------------

0 commit comments

Comments
 (0)