From 7112937b0b23a3504dd2331fabafd40192477b95 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Fri, 12 Dec 2025 04:30:50 +0000 Subject: [PATCH] Better thread pool constructor statically define a number of threads, then setup the necessary machinery to make it work. --- src/main.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 233d1dd..23f6e9c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -116,13 +116,13 @@ int main(void) std::string format_str; u64 format_str_width = 0; - // Init threads - std::thread threads[] = { - std::thread(cw::worker::worker, std::ref(state)), - std::thread(cw::worker::worker, std::ref(state)), - std::thread(cw::worker::worker, std::ref(state)), - std::thread(cw::worker::worker, std::ref(state)), - }; +// Init threads +#define THREADS 15 + std::thread threads[THREADS]; + for (auto i = 0; i < THREADS; ++i) + { + threads[i] = std::move(std::thread(cw::worker::worker, std::ref(state))); + } // Setup raylib window InitWindow(WIDTH, HEIGHT, "Calkin-Wilf tree");