mirror of
https://github.com/Relintai/thread_pool.git
synced 2024-11-12 10:25:29 +01:00
Improve the logic int _thread_finished a bit. It saves a few _thread_finished calls in certain situations.
This commit is contained in:
parent
1e2a611ebd
commit
0917511d04
@ -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_
|
||||
|
Loading…
Reference in New Issue
Block a user