From d00cdd6b2c4a274d916270872371b85e63ad342f Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Mon, 28 Nov 2016 10:49:05 -0500 Subject: [PATCH] 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. --- src/engine/runtime.js | 6 +++--- src/engine/sequencer.js | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/engine/runtime.js b/src/engine/runtime.js index 2244d1ed3..5c7b788c4 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -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(); diff --git a/src/engine/sequencer.js b/src/engine/sequencer.js index 8c732ca9c..16e07110e 100644 --- a/src/engine/sequencer.js +++ b/src/engine/sequencer.js @@ -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; }; /**