Variables
inlineread onlyMULTI_THREADED:ThreadMode = true
All work will be done on a background thread.
Unlike single-threaded mode, there is no risk of causing lag spikes.
Even so, doWork should return periodically, to allow canceling the
thread. If not canceled, doWork will be called again immediately.
In HTML5, web workers will be used to achieve this. This means doWork
must be a static function, and you can't use bind(). Web workers also
impose a longer delay each time doWork returns, so it shouldn't return
as often in multi-threaded mode as in single-threaded mode.
inlineread onlySINGLE_THREADED:ThreadMode = false
All work will be done on the main thread, during Application.onUpdate.
To avoid lag spikes, doWork should return after completing a fraction
of a frame's worth of work, storing its progress in state. It will be
called again with the same state next frame, or this frame if there's
still time.
See also: