Fix single-threaded jobs.

This commit is contained in:
Joseph Cloutier
2022-03-28 20:49:17 -04:00
parent a2e67cdba8
commit b38220b616

View File

@@ -483,7 +483,7 @@ class ThreadPool extends WorkOutput
do do
{ {
workIterations.value++; workIterations.value++;
__doWork.dispatch(state, this); activeJob.doWork.dispatch(state, this);
timeElapsed = timestamp() - startTime; timeElapsed = timestamp() - startTime;
} }
while (!__jobComplete.value && timeElapsed < __workPerFrame); while (!__jobComplete.value && timeElapsed < __workPerFrame);
@@ -496,10 +496,7 @@ class ThreadPool extends WorkOutput
activeJob.duration += timeElapsed; activeJob.duration += timeElapsed;
// Add this job to the end of the list, to cycle through. // Add this job to the end of the list, to cycle through.
if (!__jobComplete.value) __activeJobs.add(activeJob);
{
__activeJobs.add(activeJob);
}
activeJob = null; activeJob = null;
} }
@@ -540,14 +537,13 @@ class ThreadPool extends WorkOutput
onError.dispatch(threadEvent.message); onError.dispatch(threadEvent.message);
} }
// The single-threaded code removes from `__activeJobs`, so __activeJobs.remove(activeJob);
// we only have to address multi-threaded here.
#if lime_threads #if lime_threads
if (mode == MULTI_THREADED) if (mode == MULTI_THREADED)
{ {
var thread:Thread = __activeThreads[activeJob.id]; var thread:Thread = __activeThreads[activeJob.id];
__activeThreads.remove(activeJob.id); __activeThreads.remove(activeJob.id);
__activeJobs.remove(activeJob);
if (currentThreads > maxThreads || __jobQueue.isEmpty() && currentThreads > minThreads) if (currentThreads > maxThreads || __jobQueue.isEmpty() && currentThreads > minThreads)
{ {