diff --git a/src/blocks/scratch3_operators.js b/src/blocks/scratch3_operators.js index 4237f47da..75077061c 100644 --- a/src/blocks/scratch3_operators.js +++ b/src/blocks/scratch3_operators.js @@ -78,11 +78,10 @@ Scratch3OperatorsBlocks.prototype.not = function (args) { return Boolean(!args.OPERAND); }; -Scratch3OperatorsBlocks.prototype.random = function (args, util) { +Scratch3OperatorsBlocks.prototype.random = function (args) { // As a demo, this implementation of random returns after 1 second of yield. // @todo Match Scratch 2.0 implementation with int-truncation. // See: http://bit.ly/1Qc0GzC - util.yieldAndBlock(); var examplePromise = new Promise(function(resolve) { setTimeout(function() { var res = (Math.random() * (args.TO - args.FROM)) + args.FROM; diff --git a/src/engine/execute.js b/src/engine/execute.js index 632b29c82..8fbb73dfc 100644 --- a/src/engine/execute.js +++ b/src/engine/execute.js @@ -74,7 +74,6 @@ var execute = function (sequencer, thread) { var primitiveReportedValue = null; primitiveReportedValue = blockFunction(argValues, { yield: thread.yield.bind(thread), - yieldAndBlock: thread.yieldAndBlock.bind(thread), done: function() { sequencer.proceedThread(thread); }, diff --git a/src/engine/sequencer.js b/src/engine/sequencer.js index 10657d4d0..81813a141 100644 --- a/src/engine/sequencer.js +++ b/src/engine/sequencer.js @@ -32,13 +32,6 @@ Sequencer.WORK_TIME = 10; Sequencer.prototype.stepThreads = function (threads) { // Start counting toward WORK_TIME this.timer.start(); - // Check for a blocking thread. - var blockingThread = this.getBlockingThread_(threads); - if (blockingThread) { - // Attempt to resolve any timeouts, but otherwise stop stepping. - blockingThread.resolveTimeouts(); - return []; - } // List of threads which have been killed by this step. var inactiveThreads = []; // If all of the threads are yielding, we should yield. @@ -70,10 +63,6 @@ Sequencer.prototype.stepThreads = function (threads) { activeThread.status = Thread.STATUS_RUNNING; // @todo Deal with the return value } - // Has the thread gone into "blocking" mode? If so, stop stepping. - if (activeThread.status === Thread.STATUS_YIELD_BLOCK) { - return inactiveThreads; - } if (activeThread.stack.length === 0 && activeThread.status === Thread.STATUS_DONE) { // Finished with this thread - tell runtime to clean it up. @@ -89,20 +78,6 @@ Sequencer.prototype.stepThreads = function (threads) { return inactiveThreads; }; -/** - * Return the thread blocking all other threads, if one exists. - * @param {Array.} threads List of which threads to check. - * @return {?Thread} The blocking thread if one exists. - */ -Sequencer.prototype.getBlockingThread_ = function (threads) { - for (var i = 0; i < threads.length; i++) { - if (threads[i].status === Thread.STATUS_YIELD_BLOCK) { - return threads[i]; - } - } - return null; -}; - /** * Step the requested thread * @param {!Thread} thread Thread object to step diff --git a/src/engine/thread.js b/src/engine/thread.js index 781197110..746d7dcc6 100644 --- a/src/engine/thread.js +++ b/src/engine/thread.js @@ -52,21 +52,13 @@ Thread.STATUS_RUNNING = 0; */ Thread.STATUS_YIELD = 1; -/** - * Thread status for a yielded thread that should block all other threads. - * This is desirable when an asynchronous capability should appear to take - * a synchronous amount of time (e.g., color touching color). - * @const - */ -Thread.STATUS_YIELD_BLOCK = 2; - /** * Thread status for a finished/done thread. * Thread is moved to this state when the interpreter * can proceed with execution. * @const */ -Thread.STATUS_DONE = 3; +Thread.STATUS_DONE = 2; /** * Push stack and update stack frames appropriately. @@ -139,13 +131,6 @@ Thread.prototype.yield = function () { this.status = Thread.STATUS_YIELD; }; -/** - * Yields the thread and blocks other threads until unyielded. - */ -Thread.prototype.yieldAndBlock = function () { - this.status = Thread.STATUS_YIELD_BLOCK; -}; - /** * Add an execution-synced timeouts for this thread. * See also: util/yieldtimers.js:timeout