API Documentation | All Packages | All Classes | Index | Frames No Frames |
StackAndFrameManagement

Package | org.flexunit.internals.runners.statements
Class | public class StackAndFrameManagement
Inheritance | StackAndFrameManagement Object
Implements | IAsyncStatement

The `StackAndFrameManagement` decorator implements green threading to deal with flash frames. This class allows us to break execution across frames and ensure a stack overflow does not occur. It does this by starting a timer when it is asked to evaluate itself. When the timer fires, which will be the following frame, execution will resume. Each time we get to the beginning of a new test, we calculate the elapsed time versus the framerate. If we get to the point where we have used mroe than about 80% of a given frame, we then defer until the next one. This prevents the player from being locked into a single frame for the entire duration of the tests preventing it from communicating with external servers, updating the UI and potentially timing out after 15 seconds.

Public Methods

| Method | Defined By
--- | --- | ---
|  | StackAndFrameManagement(statement:IAsyncStatement) Constructor. | StackAndFrameManagement
|  | evaluate(previousToken:AsyncTestToken):void Determines if there is time in the frame to start running the IAsyncStatement. | StackAndFrameManagement
|  | handleNextExecuteComplete(result:ChildResult):void Report any errors the ChildResult has encountered to the parentToken, notifying the parentToken that we are done. | StackAndFrameManagement

Protected Methods

| Method | Defined By
--- | --- | ---
|  | handleTimerComplete(event:TimerEvent):void Evaluates the IAsyncStatement after the timer has waited and the player is now in the next frame. | StackAndFrameManagement

Constructor Detail

StackAndFrameManagement | () | Constructor

`public function StackAndFrameManagement(statement:IAsyncStatement)`

Constructor.

Parameters

| `statement:IAsyncStatement` — The current object that implements the `IAsyncStatement` to decorate.

Method Detail

evaluate | () | method

`public function evaluate(previousToken:AsyncTestToken):void`

Determines if there is time in the frame to start running the `IAsyncStatement`. If there is still time, the `IAsyncStatement` will be evaluated; otherwise, a timer will be started that will wait until the next frame before the `IAsyncStatement` is evaluated.

Parameters

| `previousToken:AsyncTestToken` — The token to be notified when that `IAsyncStatement` has finished executing.

handleNextExecuteComplete | () | method |

`public function handleNextExecuteComplete(result:ChildResult):void`

Report any errors the `ChildResult` has encountered to the parentToken, notifying the parentToken that we are done.

Parameters

| `result:ChildResult` — The `ChildResult` to check to see if there is an error.

handleTimerComplete | () | method |

`protected function handleTimerComplete(event:TimerEvent):void`

Evaluates the `IAsyncStatement` after the timer has waited and the player is now in the next frame.

Parameters

| `event:TimerEvent`

Thu Apr 10 2014, 08:07 AM +10:00