Skip to main content

spawn

Function spawn 

Source
pub fn spawn<T: Send + 'static>(
    work: impl FnOnce() -> T + Send + 'static,
    done: impl FnOnce(T) + Send + 'static,
)
Expand description

Run work on a thread of its own, then done with its result on the game thread. work must not call the engine; done may.

The library waits for every work still running before it unloads (a hot reload, the engine closing), so no thread runs code that is gone; a done still queued then is dropped.