summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/NetworkSingleton.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-01-26 14:46:20 +0100
committerMattes D <github@xoft.cz>2015-01-27 14:53:37 +0100
commit053362e604c98c229df57337ba7752d4d6b97fa8 (patch)
tree774001009deb09c66a7d3e6639a533c6f4ece721 /src/OSSupport/NetworkSingleton.h
parentcTCPLinkImpl: Added the BEV_OPT_THREADSAFE flag. (diff)
downloadcuberite-053362e604c98c229df57337ba7752d4d6b97fa8.tar
cuberite-053362e604c98c229df57337ba7752d4d6b97fa8.tar.gz
cuberite-053362e604c98c229df57337ba7752d4d6b97fa8.tar.bz2
cuberite-053362e604c98c229df57337ba7752d4d6b97fa8.tar.lz
cuberite-053362e604c98c229df57337ba7752d4d6b97fa8.tar.xz
cuberite-053362e604c98c229df57337ba7752d4d6b97fa8.tar.zst
cuberite-053362e604c98c229df57337ba7752d4d6b97fa8.zip
Diffstat (limited to '')
-rw-r--r--src/OSSupport/NetworkSingleton.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/OSSupport/NetworkSingleton.h b/src/OSSupport/NetworkSingleton.h
index 1d26fc8f4..e27e19012 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; }
@@ -113,6 +119,9 @@ protected:
/** Event that gets signalled when the event loop terminates. */
cEvent m_EventLoopTerminated;
+ /** Set to true if Terminate has been called. */
+ volatile bool m_HasTerminated;
+
/** Initializes the LibEvent internals. */
cNetworkSingleton(void);