Revert variable type.

We need to store an `ActiveJob`, not a `State`.
This commit is contained in:
Joseph Cloutier
2022-03-23 16:17:08 -04:00
parent ecddb1ec5a
commit 3eae01e7c6
2 changed files with 17 additions and 18 deletions

View File

@@ -437,8 +437,8 @@ class ThreadPool extends WorkOutput
// Run the next single-threaded job.
if (mode == SINGLE_THREADED && activeJobs > 0)
{
var activeJob:ActiveJob = __activeJobs.pop();
__activeJobState = activeJob.workEvent.state;
__activeJob = __activeJobs.pop();
var state:State = __activeJob.workEvent.state;
__jobComplete.value = false;
workIterations.value = 0;
@@ -450,7 +450,7 @@ class ThreadPool extends WorkOutput
do
{
workIterations.value++;
__doWork.dispatch(__activeJobState, this);
__doWork.dispatch(state, this);
timeElapsed = timestamp() - startTime;
}
while (!__jobComplete.value && timeElapsed < __workPerFrame);
@@ -460,16 +460,15 @@ class ThreadPool extends WorkOutput
sendError(e);
}
activeJob.workTime += timeElapsed;
__activeJob.workTime += timeElapsed;
// Add this job to the end of the list, to cycle through. (Not
// optimal for performance, but the user may have a good reason.)
// Add this job to the end of the list, to cycle through.
if (!__jobComplete.value)
{
__activeJobs.add(activeJob);
__activeJobs.add(__activeJob);
}
__activeJobState = null;
__activeJob = null;
}
var threadEvent:ThreadEvent;
@@ -489,7 +488,7 @@ class ThreadPool extends WorkOutput
}
eventData.state = threadEvent.associatedJob.workEvent.state;
eventData.duration = threadEvent.jobStartTime != 0 ? timestamp() - threadEvent.jobStartTime : threadEvent.associatedJob.workTime;
eventData.duration = mode == MULTI_THREADED ? timestamp() - threadEvent.jobStartTime : threadEvent.associatedJob.workTime;
switch (threadEvent.event)
{

View File

@@ -85,12 +85,12 @@ class WorkOutput
private var __activeJobs:ActiveJobs = new ActiveJobs();
/**
The `state` provided to the active job. Will only have a value during
`__update()` in single-threaded mode, and will otherwise be `null`.
In single-threaded mode while a job is active, the currently-active job.
Will otherwise be `null`.
Include this when creating new `ThreadEvent`s.
**/
private var __activeJobState:Null<State> = null;
private var __activeJob:Null<ActiveJob> = null;
private inline function new(mode:Null<ThreadMode>)
{
@@ -117,10 +117,10 @@ class WorkOutput
#if (lime_threads && html5)
if (mode == MULTI_THREADED)
Thread.returnMessage(new ThreadEvent(COMPLETE, message, __activeJobState, __jobStartTime.value), transferList);
Thread.returnMessage(new ThreadEvent(COMPLETE, message, __activeJob, __jobStartTime.value), transferList);
else
#end
__jobOutput.add(new ThreadEvent(COMPLETE, message, __activeJobState, __jobStartTime.value));
__jobOutput.add(new ThreadEvent(COMPLETE, message, __activeJob, __jobStartTime.value));
}
}
@@ -139,10 +139,10 @@ class WorkOutput
#if (lime_threads && html5)
if (mode == MULTI_THREADED)
Thread.returnMessage(new ThreadEvent(ERROR, message, __activeJobState, __jobStartTime.value), transferList);
Thread.returnMessage(new ThreadEvent(ERROR, message, __activeJob, __jobStartTime.value), transferList);
else
#end
__jobOutput.add(new ThreadEvent(ERROR, message, __activeJobState, __jobStartTime.value));
__jobOutput.add(new ThreadEvent(ERROR, message, __activeJob, __jobStartTime.value));
}
}
@@ -159,10 +159,10 @@ class WorkOutput
{
#if (lime_threads && html5)
if (mode == MULTI_THREADED)
Thread.returnMessage(new ThreadEvent(PROGRESS, message, __activeJobState, __jobStartTime.value), transferList);
Thread.returnMessage(new ThreadEvent(PROGRESS, message, __activeJob, __jobStartTime.value), transferList);
else
#end
__jobOutput.add(new ThreadEvent(PROGRESS, message, __activeJobState, __jobStartTime.value));
__jobOutput.add(new ThreadEvent(PROGRESS, message, __activeJob, __jobStartTime.value));
}
}