]> granicus.if.org Git - icinga2/commitdiff
Change the default number of threads for the ThreadPool class.
authorGunnar Beutner <gunnar@beutner.name>
Fri, 23 May 2014 10:35:18 +0000 (12:35 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Fri, 23 May 2014 10:35:18 +0000 (12:35 +0200)
Fixes #6279

lib/base/threadpool.cpp

index 4561920580a16edf7e246726be901d0d54fa230a..d79ec2cb2f59d9d39a562278761089780e6dae6f 100644 (file)
@@ -22,8 +22,8 @@
 #include "base/debug.h"
 #include "base/utility.h"
 #include "base/exception.h"
-#include <iostream>
 #include <boost/bind.hpp>
+#include <iostream>
 
 using namespace icinga;
 
@@ -271,8 +271,8 @@ void ThreadPool::ManagerThreadProc(void)
 
                                int tthreads = wthreads - alive;
 
-                               /* Don't ever kill the last thread. */
-                               if (alive + tthreads < 1)
+                               /* Make sure there is at least one thread per CPU */
+                               if (alive + tthreads < std::max(boost::thread::hardware_concurrency(), 4U))
                                        tthreads = 1 - alive;
 
                                /* Don't kill more than 8 threads at once. */