mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 06:23:37 -05:00
Always yield thread when a promise is returned.
This commit is contained in:
parent
9881ee76b9
commit
9a7ab57f6f
1 changed files with 6 additions and 2 deletions
|
@ -93,6 +93,11 @@ var execute = function (sequencer, thread) {
|
||||||
typeof primitiveReportedValue.then === 'function'
|
typeof primitiveReportedValue.then === 'function'
|
||||||
);
|
);
|
||||||
if (isPromise) {
|
if (isPromise) {
|
||||||
|
if (thread.status === Thread.STATUS_RUNNING) {
|
||||||
|
// Primitive returned a promise; automatically yield thread.
|
||||||
|
thread.status = Thread.STATUS_YIELD;
|
||||||
|
}
|
||||||
|
// Promise handlers
|
||||||
primitiveReportedValue.then(function(resolvedValue) {
|
primitiveReportedValue.then(function(resolvedValue) {
|
||||||
// Promise resolved: the primitive reported a value.
|
// Promise resolved: the primitive reported a value.
|
||||||
if (DEBUG_BLOCK_CALLS) {
|
if (DEBUG_BLOCK_CALLS) {
|
||||||
|
@ -107,8 +112,7 @@ var execute = function (sequencer, thread) {
|
||||||
console.warn('primitive rejected promise: ', rejectionReason);
|
console.warn('primitive rejected promise: ', rejectionReason);
|
||||||
}
|
}
|
||||||
sequencer.proceedThread(thread);
|
sequencer.proceedThread(thread);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
} else if (thread.status === Thread.STATUS_RUNNING) {
|
} else if (thread.status === Thread.STATUS_RUNNING) {
|
||||||
if (DEBUG_BLOCK_CALLS) {
|
if (DEBUG_BLOCK_CALLS) {
|
||||||
console.log('reporting value: ', primitiveReportedValue);
|
console.log('reporting value: ', primitiveReportedValue);
|
||||||
|
|
Loading…
Reference in a new issue