cIsThread: Reset m_ShouldTerminate after the thread has stopped (#4258)
This allows threads to be restarted after stopping. Fixes #4257
This commit is contained in:
parent
4fbf04413d
commit
7b431bed51
@ -79,21 +79,11 @@ cChunkSender::~cChunkSender()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cChunkSender::Start()
|
|
||||||
{
|
|
||||||
m_ShouldTerminate = false;
|
|
||||||
return super::Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunkSender::Stop(void)
|
void cChunkSender::Stop(void)
|
||||||
{
|
{
|
||||||
m_ShouldTerminate = true;
|
m_ShouldTerminate = true;
|
||||||
m_evtQueue.Set();
|
m_evtQueue.Set();
|
||||||
Wait();
|
super::Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,8 +67,6 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool Start();
|
|
||||||
|
|
||||||
void Stop(void);
|
void Stop(void);
|
||||||
|
|
||||||
/** Queues a chunk to be sent to a specific client */
|
/** Queues a chunk to be sent to a specific client */
|
||||||
|
@ -98,7 +98,7 @@ void cChunkGenerator::Stop(void)
|
|||||||
m_ShouldTerminate = true;
|
m_ShouldTerminate = true;
|
||||||
m_Event.Set();
|
m_Event.Set();
|
||||||
m_evtRemoved.Set(); // Wake up anybody waiting for empty queue
|
m_evtRemoved.Set(); // Wake up anybody waiting for empty queue
|
||||||
Wait();
|
super::Stop();
|
||||||
|
|
||||||
delete m_Generator;
|
delete m_Generator;
|
||||||
m_Generator = nullptr;
|
m_Generator = nullptr;
|
||||||
|
@ -140,7 +140,7 @@ void cLightingThread::Stop(void)
|
|||||||
m_ShouldTerminate = true;
|
m_ShouldTerminate = true;
|
||||||
m_evtItemAdded.Set();
|
m_evtItemAdded.Set();
|
||||||
|
|
||||||
Wait();
|
super::Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,8 +60,7 @@ cIsThread::cIsThread(const AString & a_ThreadName) :
|
|||||||
|
|
||||||
cIsThread::~cIsThread()
|
cIsThread::~cIsThread()
|
||||||
{
|
{
|
||||||
m_ShouldTerminate = true;
|
Stop();
|
||||||
Wait();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -110,14 +109,9 @@ bool cIsThread::Start(void)
|
|||||||
|
|
||||||
void cIsThread::Stop(void)
|
void cIsThread::Stop(void)
|
||||||
{
|
{
|
||||||
if (!m_Thread.joinable())
|
|
||||||
{
|
|
||||||
// The thread hasn't been started or has already been joined
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_ShouldTerminate = true;
|
m_ShouldTerminate = true;
|
||||||
Wait();
|
Wait();
|
||||||
|
m_ShouldTerminate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,7 +77,6 @@ void cAuthenticator::Authenticate(int a_ClientID, const AString & a_UserName, co
|
|||||||
void cAuthenticator::Start(cSettingsRepositoryInterface & a_Settings)
|
void cAuthenticator::Start(cSettingsRepositoryInterface & a_Settings)
|
||||||
{
|
{
|
||||||
ReadSettings(a_Settings);
|
ReadSettings(a_Settings);
|
||||||
m_ShouldTerminate = false;
|
|
||||||
super::Start();
|
super::Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +88,7 @@ void cAuthenticator::Stop(void)
|
|||||||
{
|
{
|
||||||
m_ShouldTerminate = true;
|
m_ShouldTerminate = true;
|
||||||
m_QueueNonempty.Set();
|
m_QueueNonempty.Set();
|
||||||
Wait();
|
super::Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ void cWorldStorage::WaitForFinish(void)
|
|||||||
// Wait for the thread to finish:
|
// Wait for the thread to finish:
|
||||||
m_ShouldTerminate = true;
|
m_ShouldTerminate = true;
|
||||||
m_Event.Set(); // Wake up the thread if waiting
|
m_Event.Set(); // Wake up the thread if waiting
|
||||||
super::Wait();
|
super::Stop();
|
||||||
LOGD("World storage thread finished");
|
LOGD("World storage thread finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user