diff --git a/include/exec/static_thread_pool.hpp b/include/exec/static_thread_pool.hpp index 5f18060f7..5b0891a5a 100644 --- a/include/exec/static_thread_pool.hpp +++ b/include/exec/static_thread_pool.hpp @@ -1745,7 +1745,13 @@ namespace experimental::execution void start() & noexcept { - std::size_t size = items_.size(); + std::size_t size = items_.size(); + if (size == 0) + { + STDEXEC::set_value(static_cast(this->rcvr_)); + return; + } + std::size_t nthreads = this->pool_.available_parallelism(); bwos_params params = this->pool_.params(); std::size_t local_size = params.blockSize * params.numBlocks; diff --git a/test/exec/test_static_thread_pool.cpp b/test/exec/test_static_thread_pool.cpp index 4d38f825e..6ae24a1cd 100644 --- a/test/exec/test_static_thread_pool.cpp +++ b/test/exec/test_static_thread_pool.cpp @@ -1,8 +1,10 @@ #include "catch2/catch_all.hpp" +#include #include #include #include +#include #include #include namespace ex = STDEXEC; @@ -45,6 +47,15 @@ TEST_CASE("bulk on static_thread_pool executes on multiple threads", "[types][st REQUIRE(thread_ids.size() == num_of_threads); } +TEST_CASE("schedule_all on static_thread_pool handles empty ranges", "[types][static_thread_pool]") +{ + exec::static_thread_pool pool{2}; + auto sender = exec::schedule_all(pool, std::views::iota(size_t{0}, size_t{0})) + | exec::ignore_all_values(); + + CHECK(ex::sync_wait(std::move(sender))); +} + TEST_CASE("bulk on static_thread_pool executes on multiple threads, take 2", "[types][static_thread_pool]") {