mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-01 00:50:24 -04:00
Add blocking yield mode
This commit is contained in:
parent
c63747e61b
commit
d44b806b4f
4 changed files with 44 additions and 2 deletions
src/engine
|
@ -52,13 +52,21 @@ 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 = 2;
|
||||
Thread.STATUS_DONE = 3;
|
||||
|
||||
/**
|
||||
* Push stack and update stack frames appropriately.
|
||||
|
@ -131,6 +139,13 @@ 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue