event/Loop: add flag alive
This replaces the old `dead` flag which was unreliable; it was `false` if the EventThread was not yet started, which could cause deadlocks in BlockingCall().
This commit is contained in:
@@ -26,8 +26,11 @@
|
||||
void
|
||||
EventThread::Start()
|
||||
{
|
||||
assert(!event_loop.IsAlive());
|
||||
assert(!thread.IsDefined());
|
||||
|
||||
event_loop.SetAlive(true);
|
||||
|
||||
thread.Start();
|
||||
}
|
||||
|
||||
@@ -35,6 +38,9 @@ void
|
||||
EventThread::Stop() noexcept
|
||||
{
|
||||
if (thread.IsDefined()) {
|
||||
assert(event_loop.IsAlive());
|
||||
event_loop.SetAlive(false);
|
||||
|
||||
event_loop.Break();
|
||||
thread.Join();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user