Clean up yield-timers: support multiple, move logic to Threads.

This commit is contained in:
Tim Mickel 2016-06-17 14:36:36 -04:00
parent 578d02cba0
commit 190208b620
4 changed files with 34 additions and 38 deletions
src/engine

View file

@ -53,10 +53,10 @@ Sequencer.prototype.stepThreads = function (threads) {
// Normal-mode thread: step.
this.startThread(activeThread);
} else if (activeThread.status === Thread.STATUS_YIELD) {
// Yield-mode thread: check if the time has passed.
if (!YieldTimers.resolve(activeThread.yieldTimerId)) {
// Thread is still yielding
// if YieldTimers.resolve returns false.
// Yield-mode thread: resolve timers.
activeThread.resolveTimeouts();
if (activeThread.status === Thread.STATUS_YIELD) {
// Still yielding.
numYieldingThreads++;
}
} else if (activeThread.status === Thread.STATUS_DONE) {