Async Execution With Jobs
This scene is very similar to the basic async demo scene. In this example the AsyncJobDemoScript
begins running the async WASM on the main thread and then finishes running the rest of it using the Unity Job System.
The running WASM code is suspended and will remain suspended until the "Complete" button is clicked. While suspended no CPU resources are used at all. Once the button is clicked it will finish running (using the Job System) and displays the difference between the two numbers.
- Open
AsyncJobsDemoScript
DemoCoroutine
calls therun()
method and receives aFuture
object.- The coroutine calls
_future.ToJob()
to convert into a Job compatibleFutureRunner<T>
. yield return future.ToJob();
will automatically schedule jobs to resume the future until it is complete.FutureRunner<T>
can be passed into a custom job.