Packageorg.generalrelativity.thread
Classpublic final class GreenThread
InheritanceGreenThread Inheritance flash.events.EventDispatcher

User-space thread emulator that manages a list of processes and considers requested frequencies and allocation constraints.

See also

http://en.wikipedia.org/wiki/Green_threads
IRunnable
GreenThreadDiagnostic


Public Properties
 PropertyDefined By
  diagnostic : GreenThreadDiagnostic
[read-only] Gets this thread's diagnostic, if any
GreenThread
  isOpen : Boolean
[read-only] Determines whether the thread is open based on the existence of runner and processes
GreenThread
  isRunning : Boolean
[read-only]
GreenThread
Public Methods
 MethodDefined By
  
GreenThread(processes:Vector.<IRunnable>, hertz:int, share:Number = 0.5, isDiagnostic:Boolean = false)
Constructor Creates a new GreenThread.
GreenThread
  
close(terminateProcesses:Boolean = true):GreenThreadDiagnostic
Closes the thread and readies itself for garbage collection
GreenThread
  
open():void
Opens the thread This is called to first open, and to reopen after forcing the thread to yield
GreenThread
  
removeProcess(process:IRunnable):void
Removes a process from the list, if actually in list
GreenThread
  
yield():void
Forces the thread to yield
GreenThread
Events
 Event Summary Defined By
  Dispatched when the thread has successfully executed all requested processesGreenThread
  Dispatched when the thread has completed a cycleGreenThread
  Dispatched whenever a process has completed executingGreenThread
  Dispatched whenever a process has thrown a script timeout exceptionGreenThread
Public Constants
 ConstantDefined By
  CYCLE : String = cycle
[static]
GreenThread
  EPSILON : int = 1
[static] Minimum contribution- will have to tweak this based on testing
GreenThread
Property Detail
diagnosticproperty
diagnostic:GreenThreadDiagnostic  [read-only]

Gets this thread's diagnostic, if any


Implementation
    public function get diagnostic():GreenThreadDiagnostic
isOpenproperty 
isOpen:Boolean  [read-only]

Determines whether the thread is open based on the existence of runner and processes


Implementation
    public function get isOpen():Boolean
isRunningproperty 
isRunning:Boolean  [read-only]


Implementation
    public function get isRunning():Boolean
Constructor Detail
GreenThread()Constructor
public function GreenThread(processes:Vector.<IRunnable>, hertz:int, share:Number = 0.5, isDiagnostic:Boolean = false)

Constructor

Creates a new GreenThread. If isDiagnostic is set to true, a diagnostic is performed during thread execution.

Parameters
processes:Vector.<IRunnable> — Sets processes
 
hertz:int — Frequency at which thread is executed
 
share:Number (default = 0.5) — Percentage of VM processor that this thread should occupy
 
isDiagnostic:Boolean (default = false) — Sets diagnostic mode

Throws
Error — if no processes are passed
Method Detail
close()method
public function close(terminateProcesses:Boolean = true):GreenThreadDiagnostic

Closes the thread and readies itself for garbage collection

Parameters

terminateProcesses:Boolean (default = true) — Flags whether to explicitly terminate all open processes

Returns
GreenThreadDiagnostic
open()method 
public function open():void

Opens the thread

This is called to first open, and to reopen after forcing the thread to yield

See also

yield
close
removeProcess()method 
public function removeProcess(process:IRunnable):void

Removes a process from the list, if actually in list

Parameters

process:IRunnable

yield()method 
public function yield():void

Forces the thread to yield

Event Detail
complete Event
Event Object Type: flash.events.Event
Event.type property = flash.event.Event.COMPLETE

Dispatched when the thread has successfully executed all requested processes

cycle Event  
Event Object Type: GreenThread
GreenThread.type property = GreenThread.CYCLE

Dispatched when the thread has completed a cycle

processComplete Event  
Event Object Type: org.generalrelativity.thread.event.GreenThreadEvent
GreenThreadEvent.type property = org.generalrelativity.thread.event.GreenThreadEvent.PROCESS_COMPLETE

Dispatched whenever a process has completed executing

processTimeout Event  
Event Object Type: org.generalrelativity.thread.event.GreenThreadEvent
GreenThreadEvent.type property = org.generalrelativity.thread.event.GreenThreadEvent.PROCESS_TIMEOUT

Dispatched whenever a process has thrown a script timeout exception

Constant Detail
CYCLEConstant
public static const CYCLE:String = cycle

EPSILONConstant 
public static const EPSILON:int = 1

Minimum contribution- will have to tweak this based on testing