Skip to main content

drain_sub_world

Function drain_sub_world 

Source
pub fn drain_sub_world(nested: &mut World)
Expand description

Run every job queued for the sub-world so far, in queue order.

Call this from the host thread before driving the world’s frame: jobs arrive at any time and must land between frames, on the host’s thread.

A job that panics ends the sub-world: the drain stops where the panic was, the world’s state reports the panic, and the queue closes so a later send is refused instead of queued for a world that will never run it. A world that has ended is left alone, collectors included: a collector is arbitrary code, and running one past a panic would hand the panic to the host.

Once the jobs have run the drain publishes what the world’s subscriptions collected, so a sub-world publishes on the host’s thread the way a threaded world publishes on its own. A world its owner has stopped publishes its last state and then ends.