shift file streaming layer to using async layer for background work, remove file stream layer thread pool

This commit is contained in:
Ryan Fleury
2024-10-31 11:44:54 -07:00
parent f3a36ece13
commit 86d9b792d8
6 changed files with 115 additions and 101 deletions
+15 -3
View File
@@ -40,9 +40,10 @@ async_push_work_(ASYNC_WorkFunctionType *work_function, ASYNC_WorkParams *params
B32 result = 0;
ASYNC_Work work = {0};
work.work_function = work_function;
work.input = params->input;
work.output = params->output;
work.semaphore = params->semaphore;
work.input = params->input;
work.output = params->output;
work.semaphore = params->semaphore;
work.completion_counter = params->completion_counter;
OS_MutexScope(async_shared->u2w_ring_mutex) for(;;)
{
U64 unconsumed_size = async_shared->u2w_ring_write_pos - async_shared->u2w_ring_read_pos;
@@ -63,6 +64,10 @@ async_push_work_(ASYNC_WorkFunctionType *work_function, ASYNC_WorkParams *params
}
os_condition_variable_wait(async_shared->u2w_ring_cv, async_shared->u2w_ring_mutex, params->endt_us);
}
if(result)
{
os_condition_variable_broadcast(async_shared->u2w_ring_cv);
}
return result;
}
@@ -127,6 +132,7 @@ async_work_thread__entry_point(void *p)
}
os_condition_variable_wait(async_shared->u2w_ring_cv, async_shared->u2w_ring_mutex, max_U64);
}
os_condition_variable_broadcast(async_shared->u2w_ring_cv);
//- rjf: run work
void *work_out = work.work_function(thread_idx, work.input);
@@ -142,5 +148,11 @@ async_work_thread__entry_point(void *p)
{
os_semaphore_drop(work.semaphore);
}
//- rjf: increment completion counter
if(work.completion_counter != 0)
{
ins_atomic_u64_inc_eval(work.completion_counter);
}
}
}
+2
View File
@@ -20,6 +20,7 @@ struct ASYNC_WorkParams
void *input;
void **output;
OS_Handle semaphore;
U64 *completion_counter;
U64 endt_us;
};
@@ -30,6 +31,7 @@ struct ASYNC_Work
void *input;
void **output;
OS_Handle semaphore;
U64 *completion_counter;
};
////////////////////////////////