Skip to main content

Module world

Module world 

Source
Expand description

Threaded worlds, which run on their own thread. Worlds the host reaches through a proxy component: one on its own thread, or one the host steps itself.

Both leave the same proxy component on the host entity, so the host’s world carries the same data either way. What differs is who drives the world: a thread of its own, or the host’s own frames.

Whoever drives a world publishes its subscriptions: a turn of the loop drains the queue, runs the tick, and then publishes what the world’s collectors returned. A tick body therefore collects nothing by hand and cannot publish twice.

Re-exportsΒ§

use async_channel::Receiver; πŸ”’
use async_channel::bounded; πŸ”’
use unlit_ecs::Bundle; πŸ”’
use unlit_ecs::DynamicBundle; πŸ”’
use unlit_ecs::Entity; πŸ”’
use unlit_ecs::EntityAccessError; πŸ”’
use unlit_ecs::World; πŸ”’
use unlit_ecs::bundle; πŸ”’
use crate::channel::publish_collected; πŸ”’
use crate::executor::LocalTasks; πŸ”’
use crate::handle::WorldHandle; πŸ”’
use crate::job::Job; πŸ”’
use crate::job::JobSender; πŸ”’
use crate::job::SendError; πŸ”’
use crate::thread::ThreadControl; πŸ”’
use crate::thread::ThreadStatus; πŸ”’
use crate::thread::WorldThread; πŸ”’
use crate::thread::panic_message; πŸ”’
use crate::thread::stepped_control; πŸ”’

StructsΒ§

Stepped
A world the host steps, with no thread of its own.
SteppedWorld πŸ”’
A world the host steps: the world, its command queue and its tick.
Threaded
A world on its own thread.
WorldEntity πŸ”’
The entity a spawned world lives on: what drives it, the name it answers to, and the queue its jobs are posted through.
WorldName
The name a spawned world answers to.
WorldProxy πŸ”’
The proxy component a spawned world leaves on the host.
WorldSender
The host-side view of a spawned world’s command queue.

EnumsΒ§

StepError
Why a stepped world could not be driven through the entity that names it.
StepOutcome
What one turn of a stepped world did.
WorldKind πŸ”’
What drives a spawned world.

TraitsΒ§

WorldRunner
How a world is driven: on its own thread, or by the host’s frames.

FunctionsΒ§

drain_all_stepped_worlds
Drain the queued jobs of every world the host steps.
run_queued_jobs πŸ”’
Run the jobs a stepped world has queued, stopping at the first panic.
spawn_stepped_world_with_init
Spawn a world the host steps, with a one-time setup step.
spawn_threaded_world
Spawn a threaded world on a fresh thread, driven by tick.
spawn_threaded_world_with_init
Like spawn_threaded_world, with a one-time setup step.
step_stepped_world
Drain a stepped world’s jobs and run its tick once with delta_seconds.
with_stepped_world
Run f against a stepped world’s world.
with_stepped_world_mut
Run f against a stepped world’s world mutably.

Type AliasesΒ§

Tick πŸ”’
The tick a world runs, with its one-time state already captured.