mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 16:48:19 +00:00
Changing semantics of thread stop methods.
PrepareStop() is now SignalStop() and just signals a thread that it should terminate. After that's called, WaitForStop() (formerly Stop()) wait for it to actually finish processing. When stopping writers during operation, we now no longer wait for them to finish.
This commit is contained in:
parent
38e1dc9ca4
commit
d11bd56b5d
6 changed files with 45 additions and 44 deletions
|
@ -117,20 +117,7 @@ void BasicThread::Start()
|
|||
OnStart();
|
||||
}
|
||||
|
||||
void BasicThread::PrepareStop()
|
||||
{
|
||||
if ( ! started )
|
||||
return;
|
||||
|
||||
if ( terminating )
|
||||
return;
|
||||
|
||||
DBG_LOG(DBG_THREADING, "Preparing thread %s to terminate ...", name);
|
||||
|
||||
OnPrepareStop();
|
||||
}
|
||||
|
||||
void BasicThread::Stop()
|
||||
void BasicThread::SignalStop()
|
||||
{
|
||||
if ( ! started )
|
||||
return;
|
||||
|
@ -140,7 +127,20 @@ void BasicThread::Stop()
|
|||
|
||||
DBG_LOG(DBG_THREADING, "Signaling thread %s to terminate ...", name);
|
||||
|
||||
OnStop();
|
||||
OnSignalStop();
|
||||
}
|
||||
|
||||
void BasicThread::WaitForStop()
|
||||
{
|
||||
if ( ! started )
|
||||
return;
|
||||
|
||||
if ( terminating )
|
||||
return;
|
||||
|
||||
DBG_LOG(DBG_THREADING, "Waiting for thread %s to terminate ...", name);
|
||||
|
||||
OnWaitForStop();
|
||||
|
||||
terminating = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue