Improve the logic int _thread_finished a bit. It saves a few _thread_finished calls in certain situations.

This commit is contained in:
Relintai 2022-02-19 16:30:34 +01:00
parent 1e2a611ebd
commit 0917511d04

View File

@ -216,12 +216,19 @@ void ThreadPool::_thread_finished(ThreadPoolContext *context) {
context->job.unref();
if (_current_queue_head != _current_queue_tail) {
while (_current_queue_head != _current_queue_tail) {
context->job = _queue.get(_current_queue_head);
if (!context->job.is_valid()) {
++_current_queue_head;
continue;
}
context->semaphore->post();
_queue.write[_current_queue_head].unref();
++_current_queue_head;
break;
}
_THREAD_SAFE_UNLOCK_