From f960dbddae55137165cb9d8886ffd1e7c3aab070 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Mon, 1 Jan 2024 20:53:26 -0500 Subject: [PATCH] thread class needs some work. use the constructor if non-queue --- include/blt/std/thread.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/blt/std/thread.h b/include/blt/std/thread.h index 38555f6..76c49ff 100644 --- a/include/blt/std/thread.h +++ b/include/blt/std/thread.h @@ -28,6 +28,7 @@ #include #include #include +#include namespace blt { @@ -46,8 +47,10 @@ namespace blt std::variant, thread_function> func_queue; std::mutex queue_mutex; public: - explicit thread_pool(std::uint64_t number_of_threads = 8) + explicit thread_pool(std::uint64_t number_of_threads = 8, std::optional default_function = {}) { + if (default_function.has_value()) + func_queue = default_function.value(); this->number_of_threads = number_of_threads; for (std::uint64_t i = 0; i < number_of_threads; i++) { @@ -77,7 +80,8 @@ namespace blt if (std::holds_alternative>(func_queue)) { std::this_thread::sleep_for(std::chrono::milliseconds(16)); - continue; + BLT_WARN("Running non queue variant with a queue inside!"); + break; } } auto& func = std::get(func_queue);