mirror of https://github.com/Icinga/icinga2.git
Replace boost::thread with std::thread
This commit is contained in:
parent
c6e36723d5
commit
7d7eaa8dd3
|
@ -35,6 +35,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
#include <boost/tuple/tuple.hpp>
|
#include <boost/tuple/tuple.hpp>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
|
@ -159,7 +160,7 @@ int Main(void)
|
||||||
Application::DeclareRLimitProcesses(Application::GetDefaultRLimitProcesses());
|
Application::DeclareRLimitProcesses(Application::GetDefaultRLimitProcesses());
|
||||||
Application::DeclareRLimitStack(Application::GetDefaultRLimitStack());
|
Application::DeclareRLimitStack(Application::GetDefaultRLimitStack());
|
||||||
#endif /* __linux__ */
|
#endif /* __linux__ */
|
||||||
Application::DeclareConcurrency(boost::thread::hardware_concurrency());
|
Application::DeclareConcurrency(std::thread::hardware_concurrency());
|
||||||
|
|
||||||
ScriptGlobal::Set("AttachDebugger", false);
|
ScriptGlobal::Set("AttachDebugger", false);
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <thread>
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
#endif /* __linux__ */
|
#endif /* __linux__ */
|
||||||
|
@ -394,7 +395,7 @@ static void ReloadProcessCallback(const ProcessResult& pr)
|
||||||
{
|
{
|
||||||
l_Restarting = false;
|
l_Restarting = false;
|
||||||
|
|
||||||
boost::thread t(std::bind(&ReloadProcessCallbackInternal, pr));
|
std::thread t(std::bind(&ReloadProcessCallbackInternal, pr));
|
||||||
t.detach();
|
t.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1508,7 +1509,7 @@ void Application::DeclareConcurrency(int ncpus)
|
||||||
*/
|
*/
|
||||||
int Application::GetConcurrency(void)
|
int Application::GetConcurrency(void)
|
||||||
{
|
{
|
||||||
Value defaultConcurrency = boost::thread::hardware_concurrency();
|
Value defaultConcurrency = std::thread::hardware_concurrency();
|
||||||
return ScriptGlobal::Get("Concurrency", &defaultConcurrency);
|
return ScriptGlobal::Get("Concurrency", &defaultConcurrency);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "base/json.hpp"
|
#include "base/json.hpp"
|
||||||
#include <boost/algorithm/string/join.hpp>
|
#include <boost/algorithm/string/join.hpp>
|
||||||
#include <boost/thread/once.hpp>
|
#include <boost/thread/once.hpp>
|
||||||
|
#include <thread>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
@ -539,7 +540,7 @@ void Process::ThreadInitialize(void)
|
||||||
{
|
{
|
||||||
/* Note to self: Make sure this runs _after_ we've daemonized. */
|
/* Note to self: Make sure this runs _after_ we've daemonized. */
|
||||||
for (int tid = 0; tid < IOTHREADS; tid++) {
|
for (int tid = 0; tid < IOTHREADS; tid++) {
|
||||||
boost::thread t(std::bind(&Process::IOThreadProc, tid));
|
std::thread t(std::bind(&Process::IOThreadProc, tid));
|
||||||
t.detach();
|
t.detach();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,7 +192,7 @@ void SocketEventEnginePoll::ChangeEvents(SocketEvents *se, int events)
|
||||||
|
|
||||||
it->second.Events = events;
|
it->second.Events = events;
|
||||||
|
|
||||||
if (se->m_EnginePrivate && boost::this_thread::get_id() == m_Threads[tid].get_id())
|
if (se->m_EnginePrivate && std::this_thread::get_id() == m_Threads[tid].get_id())
|
||||||
((pollfd *)se->m_EnginePrivate)->events = events;
|
((pollfd *)se->m_EnginePrivate)->events = events;
|
||||||
else
|
else
|
||||||
m_FDChanged[tid] = true;
|
m_FDChanged[tid] = true;
|
||||||
|
|
|
@ -50,7 +50,7 @@ void SocketEventEngine::Start(void)
|
||||||
|
|
||||||
InitializeThread(tid);
|
InitializeThread(tid);
|
||||||
|
|
||||||
m_Threads[tid] = boost::thread(std::bind(&SocketEventEngine::ThreadProc, this, tid));
|
m_Threads[tid] = std::thread(std::bind(&SocketEventEngine::ThreadProc, this, tid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ void SocketEventEngine::WakeUpThread(int sid, bool wait)
|
||||||
{
|
{
|
||||||
int tid = sid % SOCKET_IOTHREADS;
|
int tid = sid % SOCKET_IOTHREADS;
|
||||||
|
|
||||||
if (boost::this_thread::get_id() == m_Threads[tid].get_id())
|
if (std::this_thread::get_id() == m_Threads[tid].get_id())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (wait) {
|
if (wait) {
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include "base/i2-base.hpp"
|
#include "base/i2-base.hpp"
|
||||||
#include "base/socket.hpp"
|
#include "base/socket.hpp"
|
||||||
#include <boost/thread.hpp>
|
#include <thread>
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
# include <poll.h>
|
# include <poll.h>
|
||||||
|
@ -109,7 +109,7 @@ protected:
|
||||||
virtual void Unregister(SocketEvents *se) = 0;
|
virtual void Unregister(SocketEvents *se) = 0;
|
||||||
virtual void ChangeEvents(SocketEvents *se, int events) = 0;
|
virtual void ChangeEvents(SocketEvents *se, int events) = 0;
|
||||||
|
|
||||||
boost::thread m_Threads[SOCKET_IOTHREADS];
|
std::thread m_Threads[SOCKET_IOTHREADS];
|
||||||
SOCKET m_EventFDs[SOCKET_IOTHREADS][2];
|
SOCKET m_EventFDs[SOCKET_IOTHREADS][2];
|
||||||
bool m_FDChanged[SOCKET_IOTHREADS];
|
bool m_FDChanged[SOCKET_IOTHREADS];
|
||||||
boost::mutex m_EventMutex[SOCKET_IOTHREADS];
|
boost::mutex m_EventMutex[SOCKET_IOTHREADS];
|
||||||
|
|
|
@ -54,7 +54,7 @@ void ThreadPool::Start(void)
|
||||||
for (size_t i = 0; i < sizeof(m_Queues) / sizeof(m_Queues[0]); i++)
|
for (size_t i = 0; i < sizeof(m_Queues) / sizeof(m_Queues[0]); i++)
|
||||||
m_Queues[i].SpawnWorker(m_ThreadGroup);
|
m_Queues[i].SpawnWorker(m_ThreadGroup);
|
||||||
|
|
||||||
m_MgmtThread = boost::thread(std::bind(&ThreadPool::ManagerThreadProc, this));
|
m_MgmtThread = std::thread(std::bind(&ThreadPool::ManagerThreadProc, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadPool::Stop(void)
|
void ThreadPool::Stop(void)
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <boost/thread/mutex.hpp>
|
#include <boost/thread/mutex.hpp>
|
||||||
#include <boost/thread/condition_variable.hpp>
|
#include <boost/thread/condition_variable.hpp>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
@ -121,7 +122,7 @@ private:
|
||||||
|
|
||||||
boost::thread_group m_ThreadGroup;
|
boost::thread_group m_ThreadGroup;
|
||||||
|
|
||||||
boost::thread m_MgmtThread;
|
std::thread m_MgmtThread;
|
||||||
boost::mutex m_MgmtMutex;
|
boost::mutex m_MgmtMutex;
|
||||||
boost::condition_variable m_MgmtCV;
|
boost::condition_variable m_MgmtCV;
|
||||||
bool m_Stopped;
|
bool m_Stopped;
|
||||||
|
|
|
@ -20,12 +20,12 @@
|
||||||
#include "base/timer.hpp"
|
#include "base/timer.hpp"
|
||||||
#include "base/debug.hpp"
|
#include "base/debug.hpp"
|
||||||
#include "base/utility.hpp"
|
#include "base/utility.hpp"
|
||||||
#include <boost/thread/thread.hpp>
|
|
||||||
#include <boost/thread/mutex.hpp>
|
#include <boost/thread/mutex.hpp>
|
||||||
#include <boost/thread/condition_variable.hpp>
|
#include <boost/thread/condition_variable.hpp>
|
||||||
#include <boost/multi_index_container.hpp>
|
#include <boost/multi_index_container.hpp>
|
||||||
#include <boost/multi_index/ordered_index.hpp>
|
#include <boost/multi_index/ordered_index.hpp>
|
||||||
#include <boost/multi_index/key_extractors.hpp>
|
#include <boost/multi_index/key_extractors.hpp>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ typedef boost::multi_index_container<
|
||||||
|
|
||||||
static boost::mutex l_TimerMutex;
|
static boost::mutex l_TimerMutex;
|
||||||
static boost::condition_variable l_TimerCV;
|
static boost::condition_variable l_TimerCV;
|
||||||
static boost::thread l_TimerThread;
|
static std::thread l_TimerThread;
|
||||||
static bool l_StopTimerThread;
|
static bool l_StopTimerThread;
|
||||||
static TimerSet l_Timers;
|
static TimerSet l_Timers;
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ void Timer::Initialize(void)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(l_TimerMutex);
|
boost::mutex::scoped_lock lock(l_TimerMutex);
|
||||||
l_StopTimerThread = false;
|
l_StopTimerThread = false;
|
||||||
l_TimerThread = boost::thread(&Timer::TimerThreadProc);
|
l_TimerThread = std::thread(&Timer::TimerThreadProc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "base/objectlock.hpp"
|
#include "base/objectlock.hpp"
|
||||||
#include <mmatch.h>
|
#include <mmatch.h>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
#include <boost/thread/tss.hpp>
|
||||||
#include <boost/algorithm/string/split.hpp>
|
#include <boost/algorithm/string/split.hpp>
|
||||||
#include <boost/algorithm/string/classification.hpp>
|
#include <boost/algorithm/string/classification.hpp>
|
||||||
#include <boost/algorithm/string/trim.hpp>
|
#include <boost/algorithm/string/trim.hpp>
|
||||||
|
@ -1221,7 +1222,7 @@ String Utility::GetThreadName(void)
|
||||||
|
|
||||||
if (!name) {
|
if (!name) {
|
||||||
std::ostringstream idbuf;
|
std::ostringstream idbuf;
|
||||||
idbuf << boost::this_thread::get_id();
|
idbuf << std::this_thread::get_id();
|
||||||
return idbuf.str();
|
return idbuf.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ void CheckerComponent::Start(bool runtimeCreated)
|
||||||
<< "'" << GetName() << "' started.";
|
<< "'" << GetName() << "' started.";
|
||||||
|
|
||||||
|
|
||||||
m_Thread = boost::thread(std::bind(&CheckerComponent::CheckThreadProc, this));
|
m_Thread = std::thread(std::bind(&CheckerComponent::CheckThreadProc, this));
|
||||||
|
|
||||||
m_ResultTimer = new Timer();
|
m_ResultTimer = new Timer();
|
||||||
m_ResultTimer->SetInterval(5);
|
m_ResultTimer->SetInterval(5);
|
||||||
|
|
|
@ -25,12 +25,12 @@
|
||||||
#include "base/configobject.hpp"
|
#include "base/configobject.hpp"
|
||||||
#include "base/timer.hpp"
|
#include "base/timer.hpp"
|
||||||
#include "base/utility.hpp"
|
#include "base/utility.hpp"
|
||||||
#include <boost/thread/thread.hpp>
|
|
||||||
#include <boost/thread/mutex.hpp>
|
#include <boost/thread/mutex.hpp>
|
||||||
#include <boost/thread/condition_variable.hpp>
|
#include <boost/thread/condition_variable.hpp>
|
||||||
#include <boost/multi_index_container.hpp>
|
#include <boost/multi_index_container.hpp>
|
||||||
#include <boost/multi_index/ordered_index.hpp>
|
#include <boost/multi_index/ordered_index.hpp>
|
||||||
#include <boost/multi_index/key_extractors.hpp>
|
#include <boost/multi_index/key_extractors.hpp>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
@ -91,7 +91,7 @@ private:
|
||||||
boost::mutex m_Mutex;
|
boost::mutex m_Mutex;
|
||||||
boost::condition_variable m_CV;
|
boost::condition_variable m_CV;
|
||||||
bool m_Stopped;
|
bool m_Stopped;
|
||||||
boost::thread m_Thread;
|
std::thread m_Thread;
|
||||||
|
|
||||||
CheckableSet m_IdleCheckables;
|
CheckableSet m_IdleCheckables;
|
||||||
CheckableSet m_PendingCheckables;
|
CheckableSet m_PendingCheckables;
|
||||||
|
|
|
@ -54,7 +54,7 @@ void ExternalCommandListener::Start(bool runtimeCreated)
|
||||||
<< "'" << GetName() << "' started.";
|
<< "'" << GetName() << "' started.";
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
m_CommandThread = boost::thread(std::bind(&ExternalCommandListener::CommandPipeThread, this, GetCommandPath()));
|
m_CommandThread = std::thread(std::bind(&ExternalCommandListener::CommandPipeThread, this, GetCommandPath()));
|
||||||
m_CommandThread.detach();
|
m_CommandThread.detach();
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "base/objectlock.hpp"
|
#include "base/objectlock.hpp"
|
||||||
#include "base/timer.hpp"
|
#include "base/timer.hpp"
|
||||||
#include "base/utility.hpp"
|
#include "base/utility.hpp"
|
||||||
#include <boost/thread/thread.hpp>
|
#include <thread>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
|
@ -47,7 +47,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
boost::thread m_CommandThread;
|
std::thread m_CommandThread;
|
||||||
|
|
||||||
void CommandPipeThread(const String& commandPath);
|
void CommandPipeThread(const String& commandPath);
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include "icinga/compatutility.hpp"
|
#include "icinga/compatutility.hpp"
|
||||||
#include "base/timer.hpp"
|
#include "base/timer.hpp"
|
||||||
#include "base/utility.hpp"
|
#include "base/utility.hpp"
|
||||||
#include <boost/thread/thread.hpp>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
|
|
|
@ -82,7 +82,7 @@ void LivestatusListener::Start(bool runtimeCreated)
|
||||||
|
|
||||||
m_Listener = socket;
|
m_Listener = socket;
|
||||||
|
|
||||||
m_Thread = boost::thread(std::bind(&LivestatusListener::ServerThreadProc, this));
|
m_Thread = std::thread(std::bind(&LivestatusListener::ServerThreadProc, this));
|
||||||
|
|
||||||
Log(LogInformation, "LivestatusListener")
|
Log(LogInformation, "LivestatusListener")
|
||||||
<< "Created TCP socket listening on host '" << GetBindHost() << "' port '" << GetBindPort() << "'.";
|
<< "Created TCP socket listening on host '" << GetBindHost() << "' port '" << GetBindPort() << "'.";
|
||||||
|
@ -110,7 +110,7 @@ void LivestatusListener::Start(bool runtimeCreated)
|
||||||
|
|
||||||
m_Listener = socket;
|
m_Listener = socket;
|
||||||
|
|
||||||
m_Thread = boost::thread(std::bind(&LivestatusListener::ServerThreadProc, this));
|
m_Thread = std::thread(std::bind(&LivestatusListener::ServerThreadProc, this));
|
||||||
|
|
||||||
Log(LogInformation, "LivestatusListener")
|
Log(LogInformation, "LivestatusListener")
|
||||||
<< "Created UNIX socket in '" << GetSocketPath() << "'.";
|
<< "Created UNIX socket in '" << GetSocketPath() << "'.";
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "livestatus/livestatuslistener.thpp"
|
#include "livestatus/livestatuslistener.thpp"
|
||||||
#include "livestatus/livestatusquery.hpp"
|
#include "livestatus/livestatusquery.hpp"
|
||||||
#include "base/socket.hpp"
|
#include "base/socket.hpp"
|
||||||
#include <boost/thread/thread.hpp>
|
#include <thread>
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ private:
|
||||||
void ClientHandler(const Socket::Ptr& client);
|
void ClientHandler(const Socket::Ptr& client);
|
||||||
|
|
||||||
Socket::Ptr m_Listener;
|
Socket::Ptr m_Listener;
|
||||||
boost::thread m_Thread;
|
std::thread m_Thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,7 +332,7 @@ bool ApiListener::AddListener(const String& node, const String& service)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::thread thread(std::bind(&ApiListener::ListenerThreadProc, this, server));
|
std::thread thread(std::bind(&ApiListener::ListenerThreadProc, this, server));
|
||||||
thread.detach();
|
thread.detach();
|
||||||
|
|
||||||
m_Servers.insert(server);
|
m_Servers.insert(server);
|
||||||
|
@ -349,7 +349,7 @@ void ApiListener::ListenerThreadProc(const Socket::Ptr& server)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
try {
|
try {
|
||||||
Socket::Ptr client = server->Accept();
|
Socket::Ptr client = server->Accept();
|
||||||
boost::thread thread(std::bind(&ApiListener::NewClientHandler, this, client, String(), RoleServer));
|
std::thread thread(std::bind(&ApiListener::NewClientHandler, this, client, String(), RoleServer));
|
||||||
thread.detach();
|
thread.detach();
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
Log(LogCritical, "ApiListener", "Cannot accept new connection.");
|
Log(LogCritical, "ApiListener", "Cannot accept new connection.");
|
||||||
|
@ -744,7 +744,7 @@ void ApiListener::ApiReconnectTimerHandler(void)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::thread thread(std::bind(&ApiListener::AddConnection, this, endpoint));
|
std::thread thread(std::bind(&ApiListener::AddConnection, this, endpoint));
|
||||||
thread.detach();
|
thread.detach();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include "remote/httphandler.hpp"
|
#include "remote/httphandler.hpp"
|
||||||
#include "base/object.hpp"
|
#include "base/object.hpp"
|
||||||
#include "config/expression.hpp"
|
#include "config/expression.hpp"
|
||||||
#include <boost/thread/thread.hpp>
|
|
||||||
#include <boost/thread/mutex.hpp>
|
#include <boost/thread/mutex.hpp>
|
||||||
#include <boost/thread/condition_variable.hpp>
|
#include <boost/thread/condition_variable.hpp>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
Loading…
Reference in New Issue