mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Account for done threads on threadCount update
Also rename inactiveThreads -> doneThreads, since this describes them better. They are the threads that have completed in the step.
This commit is contained in:
parent
0003b294cb
commit
d00cdd6b2c
2 changed files with 8 additions and 8 deletions
|
@ -568,9 +568,9 @@ Runtime.prototype._step = function () {
|
|||
}
|
||||
}
|
||||
this.redrawRequested = false;
|
||||
var inactiveThreads = this.sequencer.stepThreads();
|
||||
this._updateGlows(inactiveThreads);
|
||||
this._setThreadCount(this.threads.length);
|
||||
var doneThreads = this.sequencer.stepThreads();
|
||||
this._updateGlows(doneThreads);
|
||||
this._setThreadCount(this.threads.length + doneThreads.length);
|
||||
if (this.renderer) {
|
||||
// @todo: Only render when this.redrawRequested or clones rendered.
|
||||
this.renderer.draw();
|
||||
|
|
|
@ -35,7 +35,7 @@ Sequencer.prototype.stepThreads = function () {
|
|||
var numActiveThreads = Infinity;
|
||||
// Whether `stepThreads` has run through a full single tick.
|
||||
var ranFirstTick = false;
|
||||
var inactiveThreads = [];
|
||||
var doneThreads = [];
|
||||
// Conditions for continuing to stepping threads:
|
||||
// 1. We must have threads in the list, and some must be active.
|
||||
// 2. Time elapsed must be less than WORK_TIME.
|
||||
|
@ -51,8 +51,8 @@ Sequencer.prototype.stepThreads = function () {
|
|||
if (activeThread.stack.length === 0 ||
|
||||
activeThread.status === Thread.STATUS_DONE) {
|
||||
// Finished with this thread.
|
||||
if (inactiveThreads.indexOf(activeThread) < 0) {
|
||||
inactiveThreads.push(activeThread);
|
||||
if (doneThreads.indexOf(activeThread) < 0) {
|
||||
doneThreads.push(activeThread);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -77,12 +77,12 @@ Sequencer.prototype.stepThreads = function () {
|
|||
}
|
||||
// Filter inactive threads from `this.runtime.threads`.
|
||||
this.runtime.threads = this.runtime.threads.filter(function (thread) {
|
||||
if (inactiveThreads.indexOf(thread) > -1) {
|
||||
if (doneThreads.indexOf(thread) > -1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return inactiveThreads;
|
||||
return doneThreads;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue