mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-04 18:40:35 -04:00
Implement thread status, YieldTimer, block glow, wait
This commit is contained in:
parent
3eeccf1970
commit
4de24cfc30
6 changed files with 739 additions and 318 deletions
src/engine
|
@ -20,6 +20,40 @@ function Thread (firstBlock) {
|
|||
* @type {Array.<string>}
|
||||
*/
|
||||
this.stack = [];
|
||||
|
||||
/**
|
||||
* Status of the thread, one of three states (below)
|
||||
* @type {number}
|
||||
*/
|
||||
this.status = 0; /* Thread.STATUS_RUNNING */
|
||||
|
||||
/**
|
||||
* Yield timer ID (for checking when the thread should unyield).
|
||||
* @type {number}
|
||||
*/
|
||||
this.yieldTimerId = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Thread status for initialized or running thread.
|
||||
* Threads are in this state when the primitive is called for the first time.
|
||||
* @const
|
||||
*/
|
||||
Thread.STATUS_RUNNING = 0;
|
||||
|
||||
/**
|
||||
* Thread status for a yielded thread.
|
||||
* Threads are in this state when a primitive has yielded.
|
||||
* @const
|
||||
*/
|
||||
Thread.STATUS_YIELD = 1;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
module.exports = Thread;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue