Replace boost::thread with std::thread

This commit is contained in:
Gunnar Beutner 2017-11-21 12:12:58 +01:00
parent c6e36723d5
commit 7d7eaa8dd3
19 changed files with 33 additions and 30 deletions

View File

@ -35,6 +35,7 @@
#include "config.h"
#include <boost/program_options.hpp>
#include <boost/tuple/tuple.hpp>
#include <thread>
#ifndef _WIN32
# include <sys/types.h>
@ -159,7 +160,7 @@ int Main(void)
Application::DeclareRLimitProcesses(Application::GetDefaultRLimitProcesses());
Application::DeclareRLimitStack(Application::GetDefaultRLimitStack());
#endif /* __linux__ */
Application::DeclareConcurrency(boost::thread::hardware_concurrency());
Application::DeclareConcurrency(std::thread::hardware_concurrency());
ScriptGlobal::Set("AttachDebugger", false);

View File

@ -40,6 +40,7 @@
#include <sstream>
#include <iostream>
#include <fstream>
#include <thread>
#ifdef __linux__
#include <sys/prctl.h>
#endif /* __linux__ */
@ -394,7 +395,7 @@ static void ReloadProcessCallback(const ProcessResult& pr)
{
l_Restarting = false;
boost::thread t(std::bind(&ReloadProcessCallbackInternal, pr));
std::thread t(std::bind(&ReloadProcessCallbackInternal, pr));
t.detach();
}
@ -1508,7 +1509,7 @@ void Application::DeclareConcurrency(int ncpus)
*/
int Application::GetConcurrency(void)
{
Value defaultConcurrency = boost::thread::hardware_concurrency();
Value defaultConcurrency = std::thread::hardware_concurrency();
return ScriptGlobal::Get("Concurrency", &defaultConcurrency);
}

View File

@ -30,6 +30,7 @@
#include "base/json.hpp"
#include <boost/algorithm/string/join.hpp>
#include <boost/thread/once.hpp>
#include <thread>
#include <iostream>
#ifndef _WIN32
@ -539,7 +540,7 @@ void Process::ThreadInitialize(void)
{
/* Note to self: Make sure this runs _after_ we've daemonized. */
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();
}
}

View File

@ -192,7 +192,7 @@ void SocketEventEnginePoll::ChangeEvents(SocketEvents *se, int 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;
else
m_FDChanged[tid] = true;

View File

@ -50,7 +50,7 @@ void SocketEventEngine::Start(void)
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;
if (boost::this_thread::get_id() == m_Threads[tid].get_id())
if (std::this_thread::get_id() == m_Threads[tid].get_id())
return;
if (wait) {

View File

@ -22,7 +22,7 @@
#include "base/i2-base.hpp"
#include "base/socket.hpp"
#include <boost/thread.hpp>
#include <thread>
#ifndef _WIN32
# include <poll.h>
@ -109,7 +109,7 @@ protected:
virtual void Unregister(SocketEvents *se) = 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];
bool m_FDChanged[SOCKET_IOTHREADS];
boost::mutex m_EventMutex[SOCKET_IOTHREADS];

View File

@ -54,7 +54,7 @@ void ThreadPool::Start(void)
for (size_t i = 0; i < sizeof(m_Queues) / sizeof(m_Queues[0]); i++)
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)

View File

@ -26,6 +26,7 @@
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
#include <deque>
#include <thread>
namespace icinga
{
@ -121,7 +122,7 @@ private:
boost::thread_group m_ThreadGroup;
boost::thread m_MgmtThread;
std::thread m_MgmtThread;
boost::mutex m_MgmtMutex;
boost::condition_variable m_MgmtCV;
bool m_Stopped;

View File

@ -20,12 +20,12 @@
#include "base/timer.hpp"
#include "base/debug.hpp"
#include "base/utility.hpp"
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/key_extractors.hpp>
#include <thread>
using namespace icinga;
@ -39,7 +39,7 @@ typedef boost::multi_index_container<
static boost::mutex l_TimerMutex;
static boost::condition_variable l_TimerCV;
static boost::thread l_TimerThread;
static std::thread l_TimerThread;
static bool l_StopTimerThread;
static TimerSet l_Timers;
@ -65,7 +65,7 @@ void Timer::Initialize(void)
{
boost::mutex::scoped_lock lock(l_TimerMutex);
l_StopTimerThread = false;
l_TimerThread = boost::thread(&Timer::TimerThreadProc);
l_TimerThread = std::thread(&Timer::TimerThreadProc);
}
/**

View File

@ -28,6 +28,7 @@
#include "base/objectlock.hpp"
#include <mmatch.h>
#include <boost/lexical_cast.hpp>
#include <boost/thread/tss.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/trim.hpp>
@ -1221,7 +1222,7 @@ String Utility::GetThreadName(void)
if (!name) {
std::ostringstream idbuf;
idbuf << boost::this_thread::get_id();
idbuf << std::this_thread::get_id();
return idbuf.str();
}

View File

@ -79,7 +79,7 @@ void CheckerComponent::Start(bool runtimeCreated)
<< "'" << 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->SetInterval(5);

View File

@ -25,12 +25,12 @@
#include "base/configobject.hpp"
#include "base/timer.hpp"
#include "base/utility.hpp"
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/key_extractors.hpp>
#include <thread>
namespace icinga
{
@ -91,7 +91,7 @@ private:
boost::mutex m_Mutex;
boost::condition_variable m_CV;
bool m_Stopped;
boost::thread m_Thread;
std::thread m_Thread;
CheckableSet m_IdleCheckables;
CheckableSet m_PendingCheckables;

View File

@ -54,7 +54,7 @@ void ExternalCommandListener::Start(bool runtimeCreated)
<< "'" << GetName() << "' started.";
#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();
#endif /* _WIN32 */
}

View File

@ -24,7 +24,7 @@
#include "base/objectlock.hpp"
#include "base/timer.hpp"
#include "base/utility.hpp"
#include <boost/thread/thread.hpp>
#include <thread>
#include <iostream>
namespace icinga
@ -47,7 +47,7 @@ protected:
private:
#ifndef _WIN32
boost::thread m_CommandThread;
std::thread m_CommandThread;
void CommandPipeThread(const String& commandPath);
#endif /* _WIN32 */

View File

@ -28,7 +28,6 @@
#include "icinga/compatutility.hpp"
#include "base/timer.hpp"
#include "base/utility.hpp"
#include <boost/thread/thread.hpp>
#include <iostream>
namespace icinga

View File

@ -82,7 +82,7 @@ void LivestatusListener::Start(bool runtimeCreated)
m_Listener = socket;
m_Thread = boost::thread(std::bind(&LivestatusListener::ServerThreadProc, this));
m_Thread = std::thread(std::bind(&LivestatusListener::ServerThreadProc, this));
Log(LogInformation, "LivestatusListener")
<< "Created TCP socket listening on host '" << GetBindHost() << "' port '" << GetBindPort() << "'.";
@ -110,7 +110,7 @@ void LivestatusListener::Start(bool runtimeCreated)
m_Listener = socket;
m_Thread = boost::thread(std::bind(&LivestatusListener::ServerThreadProc, this));
m_Thread = std::thread(std::bind(&LivestatusListener::ServerThreadProc, this));
Log(LogInformation, "LivestatusListener")
<< "Created UNIX socket in '" << GetSocketPath() << "'.";

View File

@ -24,7 +24,7 @@
#include "livestatus/livestatuslistener.thpp"
#include "livestatus/livestatusquery.hpp"
#include "base/socket.hpp"
#include <boost/thread/thread.hpp>
#include <thread>
using namespace icinga;
@ -56,7 +56,7 @@ private:
void ClientHandler(const Socket::Ptr& client);
Socket::Ptr m_Listener;
boost::thread m_Thread;
std::thread m_Thread;
};
}

View File

@ -332,7 +332,7 @@ bool ApiListener::AddListener(const String& node, const String& service)
return false;
}
boost::thread thread(std::bind(&ApiListener::ListenerThreadProc, this, server));
std::thread thread(std::bind(&ApiListener::ListenerThreadProc, this, server));
thread.detach();
m_Servers.insert(server);
@ -349,7 +349,7 @@ void ApiListener::ListenerThreadProc(const Socket::Ptr& server)
for (;;) {
try {
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();
} catch (const std::exception&) {
Log(LogCritical, "ApiListener", "Cannot accept new connection.");
@ -744,7 +744,7 @@ void ApiListener::ApiReconnectTimerHandler(void)
continue;
}
boost::thread thread(std::bind(&ApiListener::AddConnection, this, endpoint));
std::thread thread(std::bind(&ApiListener::AddConnection, this, endpoint));
thread.detach();
}
}

View File

@ -23,7 +23,6 @@
#include "remote/httphandler.hpp"
#include "base/object.hpp"
#include "config/expression.hpp"
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
#include <set>