mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-11 22:10:00 -04:00
Clean up yield-timers: support multiple, move logic to Threads.
This commit is contained in:
parent
578d02cba0
commit
190208b620
4 changed files with 34 additions and 38 deletions
src/engine
|
@ -1,5 +1,3 @@
|
|||
var YieldTimers = require('../util/yieldtimers.js');
|
||||
|
||||
/**
|
||||
* If set, block calls, args, and return values will be logged to the console.
|
||||
* @const {boolean}
|
||||
|
@ -13,11 +11,6 @@ var execute = function (sequencer, thread) {
|
|||
var currentBlockId = thread.peekStack();
|
||||
var currentStackFrame = thread.peekStackFrame();
|
||||
|
||||
// Save the yield timer ID, in case a primitive makes a new one
|
||||
// @todo hack - perhaps patch this to allow more than one timer per
|
||||
// primitive, for example...
|
||||
var oldYieldTimerId = YieldTimers.timerId;
|
||||
|
||||
var opcode = runtime.blocks.getOpcode(currentBlockId);
|
||||
|
||||
// Generate values for arguments (inputs).
|
||||
|
@ -64,17 +57,12 @@ var execute = function (sequencer, thread) {
|
|||
done: function() {
|
||||
sequencer.proceedThread(thread);
|
||||
},
|
||||
timeout: YieldTimers.timeout,
|
||||
timeout: thread.addTimeout.bind(thread),
|
||||
stackFrame: currentStackFrame,
|
||||
startSubstack: function (substackNum) {
|
||||
sequencer.stepToSubstack(thread, substackNum);
|
||||
}
|
||||
});
|
||||
// Update if the thread has set a yield timer ID
|
||||
// @todo hack
|
||||
if (YieldTimers.timerId > oldYieldTimerId) {
|
||||
thread.yieldTimerId = YieldTimers.timerId;
|
||||
}
|
||||
if (DEBUG_BLOCK_CALLS) {
|
||||
console.log('ending stack frame: ', currentStackFrame);
|
||||
console.log('returned: ', primitiveReturnValue);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue