Merge pull request #1619 from mzgoddard/execution-order-2
Execution order 2
This commit is contained in:
18 files changed
+24
-4
No files matched your search
@@ -109,7 +109,12 @@ class Scratch3EventBlocks {
|
||||
}
|
||||
// We've run before; check if the wait is still going on.
|
||||
const instance = this;
|
||||
const waiting = util.stackFrame.startedThreads.some(thread => instance.runtime.isActiveThread(thread));
|
||||
// Scratch 2 considers threads to be waiting if they are still in
|
||||
// runtime.threads. Threads that have run all their blocks, or are
|
||||
// marked done but still in runtime.threads are still considered to
|
||||
// be waiting.
|
||||
const waiting = util.stackFrame.startedThreads
|
||||
.some(thread => instance.runtime.threads.indexOf(thread) !== -1);
|
||||
if (waiting) {
|
||||
// If all threads are waiting for the next tick or later yield
|
||||
// for a tick as well. Otherwise yield until the next loop of
|
||||
|
||||
@@ -415,7 +415,12 @@ class Scratch3LooksBlocks {
|
||||
}
|
||||
// We've run before; check if the wait is still going on.
|
||||
const instance = this;
|
||||
const waiting = util.stackFrame.startedThreads.some(thread => instance.runtime.isActiveThread(thread));
|
||||
// Scratch 2 considers threads to be waiting if they are still in
|
||||
// runtime.threads. Threads that have run all their blocks, or are
|
||||
// marked done but still in runtime.threads are still considered to
|
||||
// be waiting.
|
||||
const waiting = util.stackFrame.startedThreads
|
||||
.some(thread => instance.runtime.threads.indexOf(thread) !== -1);
|
||||
if (waiting) {
|
||||
// If all threads are waiting for the next tick or later yield
|
||||
// for a tick as well. Otherwise yield until the next loop of
|
||||
|
||||
@@ -900,6 +900,8 @@ class RenderedTarget extends Target {
|
||||
// of what layers are present
|
||||
this.renderer.setDrawableOrder(this.drawableID, Infinity, StageLayering.SPRITE_LAYER);
|
||||
}
|
||||
|
||||
this.runtime.setExecutablePosition(this, Infinity);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -911,6 +913,8 @@ class RenderedTarget extends Target {
|
||||
// of what layers are present
|
||||
this.renderer.setDrawableOrder(this.drawableID, -Infinity, StageLayering.SPRITE_LAYER, false);
|
||||
}
|
||||
|
||||
this.runtime.setExecutablePosition(this, -Infinity);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -921,6 +925,8 @@ class RenderedTarget extends Target {
|
||||
if (this.renderer) {
|
||||
this.renderer.setDrawableOrder(this.drawableID, nLayers, StageLayering.SPRITE_LAYER, true);
|
||||
}
|
||||
|
||||
this.runtime.moveExecutable(this, nLayers);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -931,6 +937,8 @@ class RenderedTarget extends Target {
|
||||
if (this.renderer) {
|
||||
this.renderer.setDrawableOrder(this.drawableID, -nLayers, StageLayering.SPRITE_LAYER, true);
|
||||
}
|
||||
|
||||
this.runtime.moveExecutable(this, -nLayers);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
BIN
Binary file not shown.
@@ -74,6 +74,7 @@ test('#760 - broadcastAndWait', t => {
|
||||
// does not yield once all threads are done
|
||||
th.status = Thread.STATUS_RUNNING;
|
||||
rt.threads[1].status = Thread.STATUS_DONE;
|
||||
rt.threads.splice(1, 1);
|
||||
e.broadcastAndWait({BROADCAST_OPTION: {id: 'testBroadcastID', name: 'message'}}, util);
|
||||
t.strictEqual(th.status, Thread.STATUS_RUNNING);
|
||||
|
||||
@@ -82,7 +83,7 @@ test('#760 - broadcastAndWait', t => {
|
||||
util.thread = th;
|
||||
e.broadcastAndWait({BROADCAST_OPTION: {id: 'testBroadcastID', name: 'message'}}, util);
|
||||
t.strictEqual(rt.threads.length, 3);
|
||||
t.strictEqual(rt.threads[1].status, Thread.STATUS_RUNNING);
|
||||
t.strictEqual(rt.threads[2].status, Thread.STATUS_RUNNING);
|
||||
t.strictEqual(th.status, Thread.STATUS_YIELD);
|
||||
// yields when some restarted thread is active
|
||||
th.status = Thread.STATUS_RUNNING;
|
||||
@@ -90,7 +91,8 @@ test('#760 - broadcastAndWait', t => {
|
||||
t.strictEqual(th.status, Thread.STATUS_YIELD);
|
||||
// does not yield once all threads are done
|
||||
th.status = Thread.STATUS_RUNNING;
|
||||
rt.threads[1].status = Thread.STATUS_DONE;
|
||||
rt.threads[2].status = Thread.STATUS_DONE;
|
||||
rt.threads.splice(2, 1);
|
||||
e.broadcastAndWait({BROADCAST_OPTION: {id: 'testBroadcastID', name: 'message'}}, util);
|
||||
t.strictEqual(th.status, Thread.STATUS_RUNNING);
|
||||
|
||||
|
||||
Reference in new issue
Block a user