Fix incorrect mutex break in DN_ASYNC unqueueing
This commit is contained in:
parent
d4adf81019
commit
941f61ec34
@ -1,4 +1,4 @@
|
||||
// Generated by the DN single header generator 2025-06-29 00:14:47
|
||||
// Generated by the DN single header generator 2025-06-30 22:12:04
|
||||
|
||||
#define DN_BASE_INC_CPP
|
||||
|
||||
@ -13004,7 +13004,13 @@ struct DN_ASYNCCore
|
||||
DN_U32 join_threads;
|
||||
};
|
||||
|
||||
typedef void(DN_ASYNCWorkFunc)(void *input);
|
||||
struct DN_ASYNCWorkArgs
|
||||
{
|
||||
DN_OSThread *thread;
|
||||
void *input;
|
||||
};
|
||||
|
||||
typedef void(DN_ASYNCWorkFunc)(DN_ASYNCWorkArgs work_args);
|
||||
|
||||
struct DN_ASYNCWork
|
||||
{
|
||||
@ -13044,17 +13050,19 @@ static DN_I32 DN_ASYNC_ThreadEntryPoint_(DN_OSThread *thread)
|
||||
|
||||
DN_ASYNCJob job = {};
|
||||
for (DN_OS_MutexScope(&async->ring_mutex)) {
|
||||
if (DN_Ring_HasData(ring, sizeof(job))) {
|
||||
if (DN_Ring_HasData(ring, sizeof(job)))
|
||||
DN_Ring_Read(ring, &job, sizeof(job));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (job.work.func) {
|
||||
DN_OS_ConditionVariableBroadcast(&async->ring_write_cv); // Resume any blocked ring write(s)
|
||||
|
||||
DN_ASYNCWorkArgs args = {};
|
||||
args.input = job.work.input;
|
||||
args.thread = thread;
|
||||
|
||||
DN_Atomic_AddU32(&async->busy_threads, 1);
|
||||
job.work.func(job.work.input);
|
||||
job.work.func(args);
|
||||
DN_Atomic_SubU32(&async->busy_threads, 1);
|
||||
|
||||
if (job.completion_sem.handle != 0)
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated by the DN single header generator 2025-06-29 00:14:47
|
||||
// Generated by the DN single header generator 2025-06-30 22:12:04
|
||||
|
||||
#if !defined(DN_BASE_INC_H)
|
||||
#define DN_BASE_INC_H
|
||||
@ -7033,7 +7033,13 @@ struct DN_ASYNCCore
|
||||
DN_U32 join_threads;
|
||||
};
|
||||
|
||||
typedef void(DN_ASYNCWorkFunc)(void *input);
|
||||
struct DN_ASYNCWorkArgs
|
||||
{
|
||||
DN_OSThread *thread;
|
||||
void *input;
|
||||
};
|
||||
|
||||
typedef void(DN_ASYNCWorkFunc)(DN_ASYNCWorkArgs work_args);
|
||||
|
||||
struct DN_ASYNCWork
|
||||
{
|
||||
|
@ -16,17 +16,19 @@ static DN_I32 DN_ASYNC_ThreadEntryPoint_(DN_OSThread *thread)
|
||||
|
||||
DN_ASYNCJob job = {};
|
||||
for (DN_OS_MutexScope(&async->ring_mutex)) {
|
||||
if (DN_Ring_HasData(ring, sizeof(job))) {
|
||||
if (DN_Ring_HasData(ring, sizeof(job)))
|
||||
DN_Ring_Read(ring, &job, sizeof(job));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (job.work.func) {
|
||||
DN_OS_ConditionVariableBroadcast(&async->ring_write_cv); // Resume any blocked ring write(s)
|
||||
|
||||
DN_ASYNCWorkArgs args = {};
|
||||
args.input = job.work.input;
|
||||
args.thread = thread;
|
||||
|
||||
DN_Atomic_AddU32(&async->busy_threads, 1);
|
||||
job.work.func(job.work.input);
|
||||
job.work.func(args);
|
||||
DN_Atomic_SubU32(&async->busy_threads, 1);
|
||||
|
||||
if (job.completion_sem.handle != 0)
|
||||
|
@ -23,7 +23,13 @@ struct DN_ASYNCCore
|
||||
DN_U32 join_threads;
|
||||
};
|
||||
|
||||
typedef void(DN_ASYNCWorkFunc)(void *input);
|
||||
struct DN_ASYNCWorkArgs
|
||||
{
|
||||
DN_OSThread *thread;
|
||||
void *input;
|
||||
};
|
||||
|
||||
typedef void(DN_ASYNCWorkFunc)(DN_ASYNCWorkArgs work_args);
|
||||
|
||||
struct DN_ASYNCWork
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user