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);