From de413783c849a8e73737a82770a3384fceb34429 Mon Sep 17 00:00:00 2001 From: Kishore Nallan Date: Mon, 10 Jun 2024 17:10:43 +0530 Subject: [PATCH] Log about threadpoool exhuastion. --- include/threadpool.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/threadpool.h b/include/threadpool.h index 6382ebd6..d4b939a2 100644 --- a/include/threadpool.h +++ b/include/threadpool.h @@ -5,6 +5,7 @@ #include #include #include +#include "logger.h" class ThreadPool { public: @@ -76,6 +77,10 @@ decltype(auto) ThreadPool::enqueue(F&& f, Args&&... args) // don't allow enqueueing after stopping the pool if(!stop) { + if(tasks.size() >= workers.size()) { + LOG(WARNING) << "Threadpool exhaustion detected, task_queue_len: " + << tasks.size() << ", thread_pool_len: " << workers.size(); + } tasks.emplace(std::move(task)); } }