summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/NetworkSingleton.h
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2015-03-10 20:05:46 +0100
committerHowaner <franzi.moos@googlemail.com>2015-03-10 20:05:46 +0100
commitab420f6cfc8519fb2ec0caa7fb242517244ffcea (patch)
treec31c3538db081516d81959ed8ad00259175441a9 /src/OSSupport/NetworkSingleton.h
parentChanged return type from AbsorbWater() to void. (diff)
parentFixed client kick/crash if many block changes happend (diff)
downloadcuberite-ab420f6cfc8519fb2ec0caa7fb242517244ffcea.tar
cuberite-ab420f6cfc8519fb2ec0caa7fb242517244ffcea.tar.gz
cuberite-ab420f6cfc8519fb2ec0caa7fb242517244ffcea.tar.bz2
cuberite-ab420f6cfc8519fb2ec0caa7fb242517244ffcea.tar.lz
cuberite-ab420f6cfc8519fb2ec0caa7fb242517244ffcea.tar.xz
cuberite-ab420f6cfc8519fb2ec0caa7fb242517244ffcea.tar.zst
cuberite-ab420f6cfc8519fb2ec0caa7fb242517244ffcea.zip
Diffstat (limited to '')
-rw-r--r--src/OSSupport/NetworkSingleton.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/OSSupport/NetworkSingleton.h b/src/OSSupport/NetworkSingleton.h
index 1d26fc8f4..0536a1c82 100644
--- a/src/OSSupport/NetworkSingleton.h
+++ b/src/OSSupport/NetworkSingleton.h
@@ -4,7 +4,8 @@
// Declares the cNetworkSingleton class representing the storage for global data pertaining to network API
// such as a list of all connections, all listening sockets and the LibEvent dispatch thread.
-// This is an internal header, no-one outside OSSupport should need to include it; use Network.h instead
+// This is an internal header, no-one outside OSSupport should need to include it; use Network.h instead;
+// the only exception being the main app entrypoint that needs to call Terminate before quitting.
@@ -48,6 +49,11 @@ public:
/** Returns the singleton instance of this class */
static cNetworkSingleton & Get(void);
+ /** Terminates all network-related threads.
+ To be used only on app shutdown.
+ MSVC runtime requires that the LibEvent networking be shut down before the main() function is exitted; this is the way to do it. */
+ void Terminate(void);
+
/** Returns the main LibEvent handle for event registering. */
event_base * GetEventBase(void) { return m_EventBase; }
@@ -110,8 +116,11 @@ protected:
/** Mutex protecting all containers against multithreaded access. */
cCriticalSection m_CS;
- /** Event that gets signalled when the event loop terminates. */
- cEvent m_EventLoopTerminated;
+ /** Set to true if Terminate has been called. */
+ volatile bool m_HasTerminated;
+
+ /** The thread in which the main LibEvent loop runs. */
+ std::thread m_EventLoopThread;
/** Initializes the LibEvent internals. */