fixed event loop

This commit is contained in:
WolverinDEV 2019-07-14 12:26:47 +02:00
parent 309ce3be30
commit 49220489ca

View File

@ -160,6 +160,8 @@ void EventExecutor::_reassign_thread_names(std::unique_lock<std::mutex> &lock) {
void EventExecutor::_executor(ts::event::EventExecutor *loop) { void EventExecutor::_executor(ts::event::EventExecutor *loop) {
while(true) { while(true) {
sassert(std::addressof(loop->lock) != nullptr);
unique_lock lock(loop->lock); unique_lock lock(loop->lock);
loop->condition.wait(lock, [&] { loop->condition.wait(lock, [&] {
return loop->should_shutdown || loop->should_adjust || loop->head != nullptr; 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()) { if(index == loop->_threads.end()) {
/* TODO: Log error */ /* TODO: Log error */
} else { } else {
(*index).detach(); /* lets detach ourselfs before we delete the handle */
loop->_threads.erase(index); loop->_threads.erase(index);
} }
loop->should_adjust = ((current_threads - 1) != loop->target_threads); loop->should_adjust = ((current_threads - 1) != loop->target_threads);
return; /* we're out now! */
} else { } else {
loop->should_adjust = false; loop->should_adjust = false;
} }