Handles async events for all threads
Static variables
Static methods
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.
staticgetThreadLoop(thread:Thread):Null<EventLoop>
Available on python, hl, neko, jvm, cpp, macro
Returns the instance of EventLoop associated with thread, or null if no such
instance exists for the given thread.
Constructor
Variables
Methods
add(callb:() ‑> Void, priority:Int = 0):Event
Add a callback to be run at each loop of the event loop.
addAsync(priority:Int = 0):Event
Similar to add but will return the Event before it's started.
This is useful if you wish to hold a reference of another thread Event loop
before it runs.
addTimer(callb:() ‑> Void, delay:Float, priority:Int = 0):Event
Add a callback to be run every delay seconds until stopped
deliver():Void
Deliver after a promise(). This will throw an exception if more deliver() calls has been made than corresponding promise() calls.
dispose():Void
This should be called after you are finished with a custom event loop. It is already automatically called for threads loops.
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(threadCheck:Bool = true):Void
Perform an update of pending events.
By default, an event loop from a thread can only be triggered from this thread.
You can set threadCheck to false in the rare cases you might want otherwise.