From 6414ce3742eaf412664eda255e24ba4dcd2375ce Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 18 Feb 2020 11:39:17 +0100 Subject: [PATCH] Always use Configuration#Concurrency, not std::thread::hardware_concurrency() refs #7842 --- lib/base/io-engine.cpp | 5 +++-- lib/base/threadpool.hpp | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/base/io-engine.cpp b/lib/base/io-engine.cpp index 5dd3ee59c..056d3b9bf 100644 --- a/lib/base/io-engine.cpp +++ b/lib/base/io-engine.cpp @@ -1,5 +1,6 @@ /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */ +#include "base/configuration.hpp" #include "base/exception.hpp" #include "base/io-engine.hpp" #include "base/lazy-init.hpp" @@ -84,10 +85,10 @@ boost::asio::io_context& IoEngine::GetIoContext() return m_IoContext; } -IoEngine::IoEngine() : m_IoContext(), m_KeepAlive(boost::asio::make_work_guard(m_IoContext)), m_Threads(decltype(m_Threads)::size_type(std::thread::hardware_concurrency() * 2u)), m_AlreadyExpiredTimer(m_IoContext) +IoEngine::IoEngine() : m_IoContext(), m_KeepAlive(boost::asio::make_work_guard(m_IoContext)), m_Threads(decltype(m_Threads)::size_type(Configuration::Concurrency * 2u)), m_AlreadyExpiredTimer(m_IoContext) { m_AlreadyExpiredTimer.expires_at(boost::posix_time::neg_infin); - m_CpuBoundSemaphore.store(std::thread::hardware_concurrency() * 3u / 2u); + m_CpuBoundSemaphore.store(Configuration::Concurrency * 3u / 2u); for (auto& thread : m_Threads) { thread = std::thread(&IoEngine::RunEventLoop, this); diff --git a/lib/base/threadpool.hpp b/lib/base/threadpool.hpp index af351cd7a..f8727034a 100644 --- a/lib/base/threadpool.hpp +++ b/lib/base/threadpool.hpp @@ -4,6 +4,7 @@ #define THREADPOOL_H #include "base/atomic.hpp" +#include "base/configuration.hpp" #include "base/exception.hpp" #include "base/logger.hpp" #include @@ -36,7 +37,7 @@ class ThreadPool public: typedef std::function WorkFunction; - ThreadPool(size_t threads = std::thread::hardware_concurrency() * 2u); + ThreadPool(size_t threads = Configuration::Concurrency * 2u); ~ThreadPool(); void Start();