summaryrefslogtreecommitdiffstats
path: root/src/Root.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-10-05 14:09:42 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2020-12-18 22:03:40 +0100
commit090d8305e4e3c3ee085a897b72f2b4708e183eb8 (patch)
treee703cc7fcb7f16c85f16b094d5df0bd0a8d698e8 /src/Root.cpp
parentHorsies: don't always broadcast metadata (diff)
downloadcuberite-090d8305e4e3c3ee085a897b72f2b4708e183eb8.tar
cuberite-090d8305e4e3c3ee085a897b72f2b4708e183eb8.tar.gz
cuberite-090d8305e4e3c3ee085a897b72f2b4708e183eb8.tar.bz2
cuberite-090d8305e4e3c3ee085a897b72f2b4708e183eb8.tar.lz
cuberite-090d8305e4e3c3ee085a897b72f2b4708e183eb8.tar.xz
cuberite-090d8305e4e3c3ee085a897b72f2b4708e183eb8.tar.zst
cuberite-090d8305e4e3c3ee085a897b72f2b4708e183eb8.zip
Diffstat (limited to '')
-rw-r--r--src/Root.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/Root.cpp b/src/Root.cpp
index dbea1fd9e..9ccb18729 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -2,6 +2,7 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Root.h"
+#include "main.h"
// STD lib hreaders:
#include <iostream>
@@ -49,8 +50,18 @@
-extern bool g_RunAsService;
-cRoot * cRoot::s_Root = nullptr;
+#ifdef __clang__
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wglobal-constructors"
+#endif
+
+decltype(cRoot::s_Root) cRoot::s_Root;
+decltype(cRoot::s_NextState) cRoot::s_NextState;
+decltype(cRoot::s_StopEvent) cRoot::s_StopEvent;
+
+#ifdef __clang__
+ #pragma clang diagnostic pop
+#endif
@@ -196,7 +207,7 @@ bool cRoot::Run(cSettingsRepositoryInterface & a_OverridesRepo)
m_StartTime = std::chrono::steady_clock::now();
HandleInput();
- m_StopEvent.Wait();
+ s_StopEvent.Wait();
// Stop the server:
m_WebAdmin->Stop();
@@ -235,7 +246,7 @@ bool cRoot::Run(cSettingsRepositoryInterface & a_OverridesRepo)
LOG("Shutdown successful!");
LOG("--- Stopped Log ---");
- return m_NextState == NextState::Restart;
+ return s_NextState == NextState::Restart;
}
@@ -959,7 +970,7 @@ void cRoot::HandleInput()
cLogCommandOutputCallback Output;
AString Command;
- while (m_NextState == NextState::Run)
+ while (s_NextState == NextState::Run)
{
#ifndef _WIN32
timeval Timeout{ 0, 0 };
@@ -982,7 +993,7 @@ void cRoot::HandleInput()
return;
}
- if (m_NextState != NextState::Run)
+ if (s_NextState != NextState::Run)
{
// Already shutting down, can't execute commands
break;
@@ -1003,7 +1014,7 @@ void cRoot::HandleInput()
void cRoot::TransitionNextState(NextState a_NextState)
{
{
- auto Current = m_NextState.load();
+ auto Current = s_NextState.load();
do
{
// Stopping is final, so stops override restarts:
@@ -1012,15 +1023,15 @@ void cRoot::TransitionNextState(NextState a_NextState)
return;
}
}
- while (!m_NextState.compare_exchange_strong(Current, a_NextState));
+ while (!s_NextState.compare_exchange_strong(Current, a_NextState));
}
- if (m_NextState == NextState::Run)
+ if (s_NextState == NextState::Run)
{
return;
}
- m_StopEvent.Set();
+ s_StopEvent.Set();
#ifdef WIN32