Runner

clay.Runner (Class)

A simple Haxe class for easily running threads and calling functions on the primary thread. from https://github.com/underscorediscovery/

Usage:

  • call Runner.init() from your primary thread
  • call Runner.tick() periodically to service callbacks (i.e inside your main loop)
  • use Runner.thread(function() { ... }) to make a thread
  • use Runner.runInMainThread(function() { ... }) to run code on the main thread
  • use runInMainThreadBlocking to run code on the main thread and wait for the return value

Static Members

currentIsMainThread(): Bool

Returns true if current running thread is main thread

Returns Description
Bool Bool

isEmulatingBackgroundWithMain(): Bool

Returns true if running in background is emulated on this platform by running background code in main thread instead of using background thread.

Returns
Bool

runInMain(_fn: Function): Void

Call a function on the primary thread without waiting or blocking. If you want return values see runInMainBlocking

Name Type
_fn Function

runInBackground(fn: Function): Void

Create a background thread using the given function, or just run (deferred) the function if threads are not supported

Name Type
fn Function

Private Members

mainThread: sys.thread.Thread

queue: sys.thread.Deque<Function>