Skip to content

Commit 07dc08a

Browse files
committed
Add test to check that bulk_unchunked is called on the same thread if seq execution policy is given.
1 parent 385b183 commit 07dc08a

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

test/exec/test_system_context.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,26 @@ TEST_CASE("simple bulk_unchunked task on system context", "[types][system_schedu
233233
}
234234
}
235235

236+
TEST_CASE("bulk_unchunked with seq will run everything on one thread", "[types][system_scheduler]") {
237+
std::thread::id this_id = std::this_thread::get_id();
238+
constexpr size_t num_tasks = 16;
239+
std::thread::id pool_ids[num_tasks];
240+
exec::parallel_scheduler sched = exec::get_parallel_scheduler();
241+
242+
auto bulk_snd = ex::bulk_unchunked(ex::schedule(sched), ex::seq, num_tasks, [&](unsigned long id) {
243+
pool_ids[id] = std::this_thread::get_id();
244+
std::this_thread::sleep_for(std::chrono::milliseconds{1});
245+
});
246+
247+
ex::sync_wait(std::move(bulk_snd));
248+
249+
for (auto pool_id: pool_ids) {
250+
REQUIRE(pool_id != std::thread::id{});
251+
REQUIRE(this_id != pool_id);
252+
REQUIRE(pool_id == pool_ids[0]); // All should be the same
253+
}
254+
}
255+
236256
TEST_CASE("bulk_chunked on parallel_scheduler performs chunking", "[types][system_scheduler]") {
237257
std::atomic<bool> has_chunking = false;
238258

0 commit comments

Comments
 (0)