An event loop implementation used for sys.thread.Thread

Constructor

new()

Methods

cancel(eventHandler:EventHandler):Void

Prevent execution of a previously scheduled event in current loop.

loop():Void

Execute all pending events. Wait and execute as many events as many times promiseEvent() was called. Runs until all repeating events are cancelled and no more events is expected.

Depending on a target platform this method may be non-reentrant. It must not be called from event callbacks.

progress():NextEventTime

Executes all pending events.

The returned time stamps can be used with Sys.time() for calculations.

Depending on a target platform this method may be non-reentrant. It must not be called from event callbacks.

promise():Void

Notify this loop about an upcoming event. This makes the thread to stay alive and wait for as many events as many times .promise() was called. These events should be added via .runPromised()

repeat(event:() ‑> Void, intervalMs:Int):EventHandler

Schedule event for execution every intervalMs milliseconds in current loop.

run(event:() ‑> Void):Void

Execute event as soon as possible.

runPromised(event:() ‑> Void):Void

Add previously promised event for execution.

wait(?timeout:Float):Bool

Blocks until a new event is added or timeout (in seconds) to expires.

Depending on a target platform this method may also automatically execute arriving events while waiting. However if any event is executed it will stop waiting.

Returns true if more events are expected. Returns false if no more events expected.

Depending on a target platform this method may be non-reentrant. It must not be called from event callbacks.