diff --git a/CMakeLists.txt b/CMakeLists.txt index 4391ec6..ca25212 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.5) include(cmake/color.cmake) -set(BLT_VERSION 0.15.0) +set(BLT_VERSION 0.15.1) set(BLT_TEST_VERSION 0.0.1) set(BLT_TARGET BLT) diff --git a/include/blt/std/thread.h b/include/blt/std/thread.h index 73bd727..b51d6d0 100644 --- a/include/blt/std/thread.h +++ b/include/blt/std/thread.h @@ -47,6 +47,7 @@ namespace blt std::vector threads; std::variant, thread_function> func_queue; std::mutex queue_mutex; + bool func_loaded = false; public: explicit thread_pool(std::uint64_t number_of_threads = 8, std::optional default_function = {}) { @@ -76,14 +77,15 @@ namespace blt func(); } else { - { + if (!func_loaded){ std::scoped_lock lock(queue_mutex); if (std::holds_alternative>(func_queue)) { std::this_thread::sleep_for(std::chrono::milliseconds(16)); - BLT_WARN("Running non queue variant with a queue inside!"); - break; + //BLT_WARN("Running non queue variant with a queue inside!"); + continue; } + func_loaded = true; } auto& func = std::get(func_queue); func();