Fixed and improved restarting
Restarts are now an actual, close-as-possible to application exit+reopen.
This commit is contained in:
@@ -18,8 +18,36 @@
|
||||
|
||||
|
||||
|
||||
cNetworkSingleton::cNetworkSingleton(void):
|
||||
m_HasTerminated(false)
|
||||
cNetworkSingleton::cNetworkSingleton() :
|
||||
m_HasTerminated(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cNetworkSingleton::~cNetworkSingleton()
|
||||
{
|
||||
// Check that Terminate has been called already:
|
||||
ASSERT(m_HasTerminated);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cNetworkSingleton & cNetworkSingleton::Get(void)
|
||||
{
|
||||
static cNetworkSingleton Instance;
|
||||
return Instance;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cNetworkSingleton::Initialise(void)
|
||||
{
|
||||
// Windows: initialize networking:
|
||||
#ifdef _WIN32
|
||||
@@ -64,26 +92,7 @@ cNetworkSingleton::cNetworkSingleton(void):
|
||||
|
||||
// Create the event loop thread:
|
||||
m_EventLoopThread = std::thread(RunEventLoop, this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cNetworkSingleton::~cNetworkSingleton()
|
||||
{
|
||||
// Check that Terminate has been called already:
|
||||
ASSERT(m_HasTerminated);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cNetworkSingleton & cNetworkSingleton::Get(void)
|
||||
{
|
||||
static cNetworkSingleton Instance;
|
||||
return Instance;
|
||||
m_HasTerminated = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -44,13 +44,18 @@ typedef std::vector<cIPLookupPtr> cIPLookupPtrs;
|
||||
class cNetworkSingleton
|
||||
{
|
||||
public:
|
||||
cNetworkSingleton();
|
||||
~cNetworkSingleton();
|
||||
|
||||
/** Returns the singleton instance of this class */
|
||||
static cNetworkSingleton & Get(void);
|
||||
|
||||
/** Initialises all network-related threads.
|
||||
To be called on first run or after app restart. */
|
||||
void Initialise(void);
|
||||
|
||||
/** Terminates all network-related threads.
|
||||
To be used only on app shutdown.
|
||||
To be used only on app shutdown or restart.
|
||||
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);
|
||||
|
||||
@@ -122,10 +127,6 @@ protected:
|
||||
/** The thread in which the main LibEvent loop runs. */
|
||||
std::thread m_EventLoopThread;
|
||||
|
||||
|
||||
/** Initializes the LibEvent internals. */
|
||||
cNetworkSingleton(void);
|
||||
|
||||
/** Converts LibEvent-generated log events into log messages in MCS log. */
|
||||
static void LogCallback(int a_Severity, const char * a_Msg);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user