Skip to main content

spawn_threaded_world_with_init

Function spawn_threaded_world_with_init 

Source
pub fn spawn_threaded_world_with_init<I, S, T>(
    host: &mut World,
    name: &'static str,
    command_capacity: usize,
    init: I,
    tick: T,
) -> WorldHandle
where I: FnOnce(&mut World) -> S + Send + 'static, S: 'static, T: FnMut(&mut World, &ThreadControl, &mut S, f32) -> bool + Send + 'static,
Expand description

Like spawn_threaded_world, with a one-time setup step.

init runs on the world’s thread before the first job is drained, so a world can create the components its jobs assume exist - its physics world, say - and hand any state they need to the tick. The state it returns is passed to every tick.

§Panics

Panics when command_capacity is zero: a queue that can never hold a job would silently block every sender.