worker loop cleanup
This commit is contained in:
parent
5ec253b4aa
commit
d571a9647d
21
src/work.c
21
src/work.c
@ -391,31 +391,26 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(worker_thread_entry_point, thread_data)
|
|||||||
.is_worker = true
|
.is_worker = true
|
||||||
};
|
};
|
||||||
|
|
||||||
b32 abort = false;
|
|
||||||
while (!abort) {
|
|
||||||
sys_mutex_lock(&G.mutex);
|
sys_mutex_lock(&G.mutex);
|
||||||
{
|
while (true) {
|
||||||
/* Check for exit */
|
while (!G.workers_shutdown && !G.scheduled_work_head) {
|
||||||
if (G.workers_shutdown) {
|
|
||||||
/* Exit thread */
|
|
||||||
abort = true;
|
|
||||||
} else if (!G.scheduled_work_head) {
|
|
||||||
/* Wait for work */
|
|
||||||
sys_condition_variable_wait(&G.cv, &G.mutex);
|
sys_condition_variable_wait(&G.cv, &G.mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do work from top */
|
while (!G.workers_shutdown && G.scheduled_work_head) {
|
||||||
while (G.scheduled_work_head && !G.workers_shutdown) {
|
|
||||||
struct work *work = G.scheduled_work_head;
|
struct work *work = G.scheduled_work_head;
|
||||||
if (work) {
|
if (work) {
|
||||||
__profscope(work_pool_task);
|
__profscope(work_pool_task);
|
||||||
--G.idle_worker_count;
|
--G.idle_worker_count;
|
||||||
work_exec_single_task_maybe_release_assume_locked((struct work *)work);
|
work_exec_single_task_maybe_release_assume_locked(work);
|
||||||
++G.idle_worker_count;
|
++G.idle_worker_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if (G.workers_shutdown) {
|
||||||
sys_mutex_unlock(&G.mutex);
|
sys_mutex_unlock(&G.mutex);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user