Handles async events for all threads

Static variables

staticread onlycurrent:EventLoop

This is the current thread event loop. For platforms that doesn't support threads it is the same as main.

staticread onlymain:EventLoop

This is the main thread event loop.

Static methods

@:value({ blocking : true })staticaddTask(f:() ‑> Void, blocking:Bool = true):Void

Add a task to be run either on another thread or as part of the main event loop if the platform does not support threads.

statichasRunningThreads():Bool

Tells if we currently have blocking unfinished threads.

Constructor

new()

Methods

@:value({ priority : 0 })add(callb:() ‑> Void, priority:Int = 0):Event

Add a callback to be run at each loop of the event loop.

@:value({ priority : 0 })addTimer(callb:() ‑> Void, delay:Float, priority:Int = 0):Event

Add a callback to be run every delay seconds until stopped

@:value({ blocking : true })hasEvents(blocking:Bool = true):Bool

Tells if the event loop has remaining events. If blocking is set to true, only check if it has remaining blocking events.

loop():Void

Runs until all the blocking events have been stopped. If this is called on the main thread, also wait for all blocking threads to finish.

loopOnce():Void

Perform an update of pending events.

@:value({ priority : 0 })run(callb:() ‑> Void, priority:Int = 0):Event

Add a function to be run once at next loop of the event loop.