Skip to main content

spawn_sub_world

Function spawn_sub_world 

Source
pub fn spawn_sub_world(
    host: &mut World,
    name: &'static str,
    command_capacity: usize,
) -> WorldHandle
Expand description

Spawn a sub-world that shares the host’s thread, nested as a World component of the returned entity, with a command inbox of the given capacity.

name labels the world for a bridge that lists the host’s worlds; it lands on the host entity as a WorldName.

Sub-worlds are for work that must stay on the host thread — rendering into a window’s swap chain, say — but whose state should not mix with the host’s. Queued jobs run when the host calls drain_sub_world, and the world itself is reached with a World query on the entity the returned handle names.

§Panics

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