fixed event loop
This commit is contained in:
parent
309ce3be30
commit
49220489ca
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user