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
2 changes: 1 addition & 1 deletion include/exec/static_thread_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ namespace exec {

static_thread_pool_* pool_;
remote_queue* queue_;
const nodemask* nodemask_;
const nodemask* nodemask_ = &nodemask::any();
std::size_t thread_idx_{std::numeric_limits<std::size_t>::max()};

public:
Expand Down
1 change: 1 addition & 0 deletions test/exec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ set(exec_test_sources
test_trampoline_scheduler.cpp
test_sequence_senders.cpp
test_sequence.cpp
test_static_thread_pool.cpp
test_just_from.cpp
sequence/test_any_sequence_of.cpp
sequence/test_empty_sequence.cpp
Expand Down
22 changes: 22 additions & 0 deletions test/exec/test_static_thread_pool.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "catch2/catch.hpp"
#include <exec/static_thread_pool.hpp>
#include <stdexec/execution.hpp>

#include <thread>
#include <unordered_set>
namespace ex = stdexec;

TEST_CASE(
"static_thread_pool::get_scheduler_on_thread Test start on a specific thread",
"[types][static_thread_pool]") {
constexpr const size_t num_of_threads = 5;
exec::static_thread_pool pool{num_of_threads};

std::unordered_set<std::thread::id> thread_ids;
for (size_t i = 0; i < num_of_threads; ++i) {
auto sender = ex::schedule(pool.get_scheduler_on_thread(i))
| ex::then([&] { thread_ids.insert(std::this_thread::get_id()); });
ex::sync_wait(std::move(sender));
}
REQUIRE(thread_ids.size() == num_of_threads);
}