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;
|
this.redrawRequested = false;
|
||||||
var inactiveThreads = this.sequencer.stepThreads();
|
var doneThreads = this.sequencer.stepThreads();
|
||||||
this._updateGlows(inactiveThreads);
|
this._updateGlows(doneThreads);
|
||||||
this._setThreadCount(this.threads.length);
|
this._setThreadCount(this.threads.length + doneThreads.length);
|
||||||
if (this.renderer) {
|
if (this.renderer) {
|
||||||
// @todo: Only render when this.redrawRequested or clones rendered.
|
// @todo: Only render when this.redrawRequested or clones rendered.
|
||||||
this.renderer.draw();
|
this.renderer.draw();
|
||||||
|
|
|
@ -35,7 +35,7 @@ Sequencer.prototype.stepThreads = function () {
|
||||||
var numActiveThreads = Infinity;
|
var numActiveThreads = Infinity;
|
||||||
// Whether `stepThreads` has run through a full single tick.
|
// Whether `stepThreads` has run through a full single tick.
|
||||||
var ranFirstTick = false;
|
var ranFirstTick = false;
|
||||||
var inactiveThreads = [];
|
var doneThreads = [];
|
||||||
// Conditions for continuing to stepping threads:
|
// Conditions for continuing to stepping threads:
|
||||||
// 1. We must have threads in the list, and some must be active.
|
// 1. We must have threads in the list, and some must be active.
|
||||||
// 2. Time elapsed must be less than WORK_TIME.
|
// 2. Time elapsed must be less than WORK_TIME.
|
||||||
|
@ -51,8 +51,8 @@ Sequencer.prototype.stepThreads = function () {
|
||||||
if (activeThread.stack.length === 0 ||
|
if (activeThread.stack.length === 0 ||
|
||||||
activeThread.status === Thread.STATUS_DONE) {
|
activeThread.status === Thread.STATUS_DONE) {
|
||||||
// Finished with this thread.
|
// Finished with this thread.
|
||||||
if (inactiveThreads.indexOf(activeThread) < 0) {
|
if (doneThreads.indexOf(activeThread) < 0) {
|
||||||
inactiveThreads.push(activeThread);
|
doneThreads.push(activeThread);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -77,12 +77,12 @@ Sequencer.prototype.stepThreads = function () {
|
||||||
}
|
}
|
||||||
// Filter inactive threads from `this.runtime.threads`.
|
// Filter inactive threads from `this.runtime.threads`.
|
||||||
this.runtime.threads = this.runtime.threads.filter(function (thread) {
|
this.runtime.threads = this.runtime.threads.filter(function (thread) {
|
||||||
if (inactiveThreads.indexOf(thread) > -1) {
|
if (doneThreads.indexOf(thread) > -1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
return inactiveThreads;
|
return doneThreads;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue