]> granicus.if.org Git - icinga2/commitdiff
Replace boost::thread with std::thread
authorGunnar Beutner <gunnar.beutner@icinga.com>
Tue, 21 Nov 2017 11:12:58 +0000 (12:12 +0100)
committerGunnar Beutner <gunnar.beutner@icinga.com>
Thu, 30 Nov 2017 16:39:20 +0000 (17:39 +0100)
19 files changed:
icinga-app/icinga.cpp
lib/base/application.cpp
lib/base/process.cpp
lib/base/socketevents-poll.cpp
lib/base/socketevents.cpp
lib/base/socketevents.hpp
lib/base/threadpool.cpp
lib/base/threadpool.hpp
lib/base/timer.cpp
lib/base/utility.cpp
lib/checker/checkercomponent.cpp
lib/checker/checkercomponent.hpp
lib/compat/externalcommandlistener.cpp
lib/compat/externalcommandlistener.hpp
lib/compat/statusdatawriter.hpp
lib/livestatus/livestatuslistener.cpp
lib/livestatus/livestatuslistener.hpp
lib/remote/apilistener.cpp
lib/remote/eventqueue.hpp

index f5665c9830d9f969206ef169560caef33fd213a5..a0d75293cf757613b3246e074019c3a92d3f7c92 100644 (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);
 
index 43a69e8934257d27da01db1d1fd0ba9361356b96..23847c03bd850a3034dcf08486c5dc1bbc449706 100644 (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);
 }
 
index 3d0cd5d3e9815bad364cacb480ab9d0c0376b077..a8f354088df4aa07cab74631b72473d4cca28684 100644 (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();
        }
 }
index 76c13cfc64be1b66c2972916c0ca009eddb415eb..d141abe951cb7710cfa7df5a5c298324bc1f5203 100644 (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;
index 00ca0c525c287cfded08faea05b48ca1e3548494..8b77da1a0091f3de024d5def23e751a54ab3c01b 100644 (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) {
index b659cc32112125bbf5f5593ac9be2de087f4b875..c40d36430792dfe1d2bd567c4975978ff1824863 100644 (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];
index 0c2925f9be9aca58ba8f5c139cd1551c9306776d..df5152d6085e6ec40b0cd7367d1eca602c1145c3 100644 (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)
index d37ca8366b4e72ffe80c16dd63277b533922c5bc..d49ffa414fcdc3836e430f4c4e8d0473d76c1cd5 100644 (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;
index 9c1a2c4a1c46a368122db809ae1b0adf0e86c6ea..3e6099da9b1018cd9f27187fcc9ab3342ef4f5ac 100644 (file)
 #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);
 }
 
 /**
index d98aebbfbce75f0a305153f4cbd2db29526da188..02238f7120b453f128801b4823982a3c2567c431 100644 (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();
        }
 
index a943872b954b7d5f5fae444b998ec9cebe845540..406bca10bb15eb4a37de430c20041c24f3532e8d 100644 (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);
index 988d3d180aa92abe36ec2aa90c3b44cab1690216..2459e8958f8fbd09727de8a191993d7be4af3874 100644 (file)
 #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;
index 0402551601f31564e6b879f06c7c043527b2b398..b426f35631299ce641f4a371df828cb1191fdd97 100644 (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 */
 }
index 02df0ded38b26f406c8535360c558df380f9fed7..b40a1c940c500522588d42d09a17f5aa0415b425 100644 (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 */
index 3a0460fd307b5a20835bb9a693e1df7d3a30372c..4b4e234d5bbee7c7c657dd225dca4fca47558b86 100644 (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
index ae0cbc1e62baa4d379df030a3f056f104396b648..3fc7391ed7826f2f74b46e55288c7f4ba35f247c 100644 (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() << "'.";
index 56be37c058cdcc29a1939bd8e4751b62dce23037..6f23f604012c501a502b6300120ea51f16e1abcc 100644 (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;
 };
 
 }
index 60c75210d68583d64123e11363e836c6e29153ea..b64b3c3ddba405126fc9132367c895dfa95c3da7 100644 (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();
                }
        }
index a9e66ee13b31b2bef32b708da54aaab15c91b686..893fd8efe9bc4e76651c7cf73764848a52074a3c 100644 (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>