Implement thread status, YieldTimer, block glow, wait

This commit is contained in:
Tim Mickel 2016-05-02 18:09:02 -04:00
parent 3eeccf1970
commit 4de24cfc30
6 changed files with 739 additions and 318 deletions
src/engine

View file

@ -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;