This commit is contained in:
Reece Wilson 2023-09-05 22:22:13 +01:00
parent 3adb019cf1
commit 213ed6c49b

View File

@ -521,12 +521,18 @@ namespace Aurora::Async
}
while (state->pendingWorkItems.empty() && block);
if (!block && // quick hack: is worthy of io reset by virtue of having polled externally (most likely)?
group->workQueue.IsEmpty(this, state->id))
if (!block) // quick hack: is worthy of io reset by virtue of having polled externally (most likely for IO ticks, unlikely for intraprocess ticks)
{
state->eventLs->Reset();
AuAtomicStore(&state->cvLSActive, 0u);
AU_LOCK_GUARD(group->workQueue.mutex); // dont atomically increment our work counters [signal under mutex group]...
AU_LOCK_GUARD(group->workersMutex); // dont atomically increment our work counters [broadcast]...
// ...these primitives are far less expensive to hit than resetting kernel primitives
// AU_LOCK_GUARD(state->cvWorkMutex) used to protect us
if (group->workQueue.IsEmpty(this, state->id))
{
state->eventLs->Reset(); // ...until we're done
AuAtomicStore(&state->cvLSActive, 0u);
}
}
AuAtomicSub(&state->cvSleepCount, 1u);