1
0

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:
peterbell10 2018-07-22 22:35:58 +01:00 committed by GitHub
parent 4fbf04413d
commit 7b431bed51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 7 additions and 26 deletions

View File

@ -79,21 +79,11 @@ cChunkSender::~cChunkSender()
bool cChunkSender::Start()
{
m_ShouldTerminate = false;
return super::Start();
}
void cChunkSender::Stop(void)
{
m_ShouldTerminate = true;
m_evtQueue.Set();
Wait();
super::Stop();
}

View File

@ -67,8 +67,6 @@ public:
};
bool Start();
void Stop(void);
/** Queues a chunk to be sent to a specific client */

View File

@ -98,7 +98,7 @@ void cChunkGenerator::Stop(void)
m_ShouldTerminate = true;
m_Event.Set();
m_evtRemoved.Set(); // Wake up anybody waiting for empty queue
Wait();
super::Stop();
delete m_Generator;
m_Generator = nullptr;

View File

@ -140,7 +140,7 @@ void cLightingThread::Stop(void)
m_ShouldTerminate = true;
m_evtItemAdded.Set();
Wait();
super::Stop();
}

View File

@ -60,8 +60,7 @@ cIsThread::cIsThread(const AString & a_ThreadName) :
cIsThread::~cIsThread()
{
m_ShouldTerminate = true;
Wait();
Stop();
}
@ -110,14 +109,9 @@ bool cIsThread::Start(void)
void cIsThread::Stop(void)
{
if (!m_Thread.joinable())
{
// The thread hasn't been started or has already been joined
return;
}
m_ShouldTerminate = true;
Wait();
m_ShouldTerminate = false;
}

View File

@ -77,7 +77,6 @@ void cAuthenticator::Authenticate(int a_ClientID, const AString & a_UserName, co
void cAuthenticator::Start(cSettingsRepositoryInterface & a_Settings)
{
ReadSettings(a_Settings);
m_ShouldTerminate = false;
super::Start();
}
@ -89,7 +88,7 @@ void cAuthenticator::Stop(void)
{
m_ShouldTerminate = true;
m_QueueNonempty.Set();
Wait();
super::Stop();
}

View File

@ -94,7 +94,7 @@ void cWorldStorage::WaitForFinish(void)
// Wait for the thread to finish:
m_ShouldTerminate = true;
m_Event.Set(); // Wake up the thread if waiting
super::Wait();
super::Stop();
LOGD("World storage thread finished");
}