Expand description
Asynchronous task handler. See TaskPoolHandler
for more info and usage examples.
Structs§
- Task
Pool Handler - Asynchronous task handler is used as an executor for async functions (tasks), that in addition to them has a closure, that will be called when a task is finished. The main use case for such tasks is to off-thread a heavy task to one of background threads (from a thread pool on PC, or a microtask on WebAssembly) and when it is done, incorporate its result in your game’s state. A task and its “on-complete” closure could be pretty much anything: procedural world generation + adding a generated scene to the engine, asset loading + its instantiation, etc. It should be noted that a task itself is executed asynchronously (in other thread), while a closure - synchronously, just at the beginning of the next game loop iteration. This means, that you should never put heavy tasks into the closure, otherwise it will result in quite notable stutters.