pub struct App { /* private fields */ }Expand description
A world and the headless loop that runs it.
run drives the world until a system stops it or its last
system finishes; run_for is the bounded form, for a test
or a tool that wants a known number of ticks. Both start the world if the
caller has not.
In dev builds the loop holds itself to a steady state of no allocation per
tick, which is asserted rather than assumed. See run.
Implementations§
Source§impl App
impl App
Sourcepub fn from_world(world: World) -> Self
pub fn from_world(world: World) -> Self
An app that runs world with no systems over it: what a caller gets
when the host contributes no system table.
Sourcepub fn with_systems(world: World, table: &'static SystemTable) -> Self
pub fn with_systems(world: World, table: &'static SystemTable) -> Self
An app that runs world under table, which is what gives it systems.
Sourcepub fn start(&mut self) -> Result<(), CnResult>
pub fn start(&mut self) -> Result<(), CnResult>
Build the world’s systems and run their init. Runs once: a second
call is InvalidState rather than a second
init over the running world.
Sourcepub fn run(&mut self) -> Result<StepResult, CnResult>
pub fn run(&mut self) -> Result<StepResult, CnResult>
Step until a system stops the world or the last one finishes, returning which of the two ended the run.
Under debug_assertions the loop asserts its own steady state: past a
warmup, a settled world’s tick allocates nothing, and a stretch of ticks
that all allocate is a cost that would recur every frame for the life of
the app, so the run panics naming the tick that allocated least. The
counters behind that are process-wide, so the check stands down where it
cannot trust them: where no binary installed the tracking allocator, and
where another thread is allocating alongside the loop.