Interface org.as2lib.app.exec.Process

Description

Process represents the access to a lacy execution.

Process can be used as access to application code that executes with a time delay. This can be eighter file requests or time consuming algorithms that have to be delayed to prevent player timeouts.

Any Process implementation can be started with start.

Any Process can send events defined in following interfaces: ProcessStartListener, ProcessErrorListener, ProcessFinishListener, ProcessPauseListener, ProcessResumeListener, ProcessUpdateListener

To listen to the events implement one or more of the above interfaces and add the listener with addListener as listener to the Process.

See Also

Method Index

getDuration(), getErrors(), getEstimatedRestTime(), getEstimatedTotalTime(), getParentProcess(), getPercentage(), hasError(), hasFinished(), hasStarted(), isPaused(), isRunning(), setParentProcess(), start()

Inherited from EventListenerSource

Inherited from BasicInterface

Method Detail

start

public function start()

Starts the execution of this process.

It is possible that the process finishes execution before returning the from this method, but it is also possible that it finishes after returning from this method. This rule exists to not loose unnecessary performance by simple accepting that every process has to be finished after this execution.

Problematic example: class MyClass implements ProcessFinishListener { private var processStarted:Boolean public function MyClass(Void) { processStarted = false; } public function doSomething(Void):Void { var process:Process = new MyProcess(); process.start(); process.addListener(this); processStarted = true; } public function onFinishProcess(process:Process):Void { if (processStarted) { // do something processStarted = false; } else { // throw an error (will be called if the process finishes immediatly. } } }

Any Process is allowed to take arguments for its execution or return a result of its execution.

Return

(optiona) result for the start (implementation specific).

hasStarted

public function hasStarted(Void):Boolean

Flag if the process has been started.

Return

true if the process has been started and isn't finish yet else false.

hasFinished

public function hasFinished(Void):Boolean

Returns true if the process has been finished else false.

A Process can only be finished if it has been started with start()

Return

true if the process has been finished else false

isPaused

public function isPaused(Void):Boolean

Returns true if the process has been started and has been paused.

A Process is allowed to be paused, this indicates that the process is actually waiting for something.

Return

true if the process has been started and has been paused

isRunning

public function isRunning(Void):Boolean

Returns true if the process has been started and is not paused.

A Process is allowed to be paused, this indicates that the process is actually not waiting for something.

Return

true if the process has been started and is not paused

getPercentage

public function getPercentage(Void):Number

Returns the percentage of execution

There are several possibilies of return values:

If the execution has not been started and the percentage will be evaluateable for sure it will return 0.

If the execution has been started and the percentage is evaluateable, it returns the current amount of percentage from 0- 100.

If the execution has finished and the percentage was evaluateable, it returns 100.

In any other case it will return null.

Return

current percentage of execution

setParentProcess

public function setParentProcess(process:Process):Void

Allows the integration and access to a process hierarchy.

Parameters

process Process that started the current process.

Throws

IllegalArgumentExceptionif the passed-in process has the current process within the parent process list or if the passed-in process is the same process as the current process.

getParentProcess

public function getParentProcess(Void):Process

Returns the parent Process set with setParentProcess.

Return

parent process if available, else null.

getErrors

public function getErrors(Void):Array

Returns the occured errors published with onProcessError during exeuction of the Process in an array.

Return

all occured errors during the execution of the event

hasError

public function hasError(Void):Boolean

Checks if an error occured during execution of the Process.

Return

true if an error occured, else false

getDuration

public function getDuration(Void):Time

By using start() it saves the start time of the execution of the process.

This method allows access to the total execution time of the process. The total execution time get evaluated by comparing start time with end time or (if the process has not finished yet) with the current time.

Return

time difference between start time and finish time or current point

getEstimatedTotalTime

public function getEstimatedTotalTime(Void):Time

Evaluates the expected total time of execution.

If the Process has been finished it returns the final total time of the execution.

If the Process has not been started it returns a estimated total time of 0.

Return

estimated time difference between start and finish time

getEstimatedRestTime

public function getEstimatedRestTime(Void):Time

Evaluates the expected rest time until the execution finishes.

If the Process has been finished it returns 0. If it has not been started it returns null.

Return

estimated rest time of the execution of the process.