mirror of https://github.com/Icinga/icinga2.git
Always use Configuration#Concurrency, not std:🧵:hardware_concurrency()
refs #7842
This commit is contained in:
parent
099cc5d8df
commit
6414ce3742
|
@ -1,5 +1,6 @@
|
||||||
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
||||||
|
|
||||||
|
#include "base/configuration.hpp"
|
||||||
#include "base/exception.hpp"
|
#include "base/exception.hpp"
|
||||||
#include "base/io-engine.hpp"
|
#include "base/io-engine.hpp"
|
||||||
#include "base/lazy-init.hpp"
|
#include "base/lazy-init.hpp"
|
||||||
|
@ -84,10 +85,10 @@ boost::asio::io_context& IoEngine::GetIoContext()
|
||||||
return m_IoContext;
|
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_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) {
|
for (auto& thread : m_Threads) {
|
||||||
thread = std::thread(&IoEngine::RunEventLoop, this);
|
thread = std::thread(&IoEngine::RunEventLoop, this);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#define THREADPOOL_H
|
#define THREADPOOL_H
|
||||||
|
|
||||||
#include "base/atomic.hpp"
|
#include "base/atomic.hpp"
|
||||||
|
#include "base/configuration.hpp"
|
||||||
#include "base/exception.hpp"
|
#include "base/exception.hpp"
|
||||||
#include "base/logger.hpp"
|
#include "base/logger.hpp"
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
@ -36,7 +37,7 @@ class ThreadPool
|
||||||
public:
|
public:
|
||||||
typedef std::function<void ()> WorkFunction;
|
typedef std::function<void ()> WorkFunction;
|
||||||
|
|
||||||
ThreadPool(size_t threads = std::thread::hardware_concurrency() * 2u);
|
ThreadPool(size_t threads = Configuration::Concurrency * 2u);
|
||||||
~ThreadPool();
|
~ThreadPool();
|
||||||
|
|
||||||
void Start();
|
void Start();
|
||||||
|
|
Loading…
Reference in New Issue