From 49220489ca3f7d27fe5d6b57eb315c6b93eb147e Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sun, 14 Jul 2019 12:26:47 +0200 Subject: [PATCH] fixed event loop --- src/EventLoop.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/EventLoop.cpp b/src/EventLoop.cpp index 046db2b..2b588f0 100644 --- a/src/EventLoop.cpp +++ b/src/EventLoop.cpp @@ -160,6 +160,8 @@ void EventExecutor::_reassign_thread_names(std::unique_lock &lock) { void EventExecutor::_executor(ts::event::EventExecutor *loop) { while(true) { + sassert(std::addressof(loop->lock) != nullptr); + unique_lock lock(loop->lock); loop->condition.wait(lock, [&] { return loop->should_shutdown || loop->should_adjust || loop->head != nullptr; @@ -177,9 +179,11 @@ void EventExecutor::_executor(ts::event::EventExecutor *loop) { if(index == loop->_threads.end()) { /* TODO: Log error */ } else { + (*index).detach(); /* lets detach ourselfs before we delete the handle */ loop->_threads.erase(index); } loop->should_adjust = ((current_threads - 1) != loop->target_threads); + return; /* we're out now! */ } else { loop->should_adjust = false; }