Skip to main content

Module app

Module app 

Source
Expand description

App builder and Plugin trait. Wraps [bevy_ecs::World] and Schedule directly without depending on bevy_app.

§Two-world architecture

App holds a main world for app/UI state and a render world for per-frame extracted draw data and GPU resources. Cross-world flow is documented in crate::render_world.

§Tick

Each call to App::tick runs:

  1. Tick advance(), bumping the frame counter and dt.
  2. The main schedule, ordered Input -> CommandDrain -> Systems -> LayoutSync -> A11ySync.

Steps 3 to 5 run only when FrameDirty is set; an idle tick stops after step 2.

  1. clear_extracted on the render world to remove transient Extracted* entities.
  2. Every registered ExtractFn against (&mut main, &mut render). The main world is taken mutably because bevy_ecs::world::World::query mutates the world’s query cache; extract does not change main-world state.
  3. The render schedule on the render world, ordered Prepare -> Render.

Structs§

App
Lumen application holding the main world, render world, their schedules, and the extract-fn list.
EventLoopWaker
Cross-thread handle used to wake a parked platform event loop after something is pushed onto a resource the tick loop doesn’t otherwise observe until the next OS event - e.g. lumen-mcp’s SimulateQueue filling from the MCP server thread while lumen-window-winit’s winit loop sits parked in about_to_wait. Without a wakeup, injected input is invisible until an unrelated OS event (mouse move, resize, …) happens to tick the app.
Tick
Schedule label for the main tick.

Enums§

AppError
Errors returned by builder methods that can fail.

Constants§

LUMEN_DEFAULT_THREADS
Upper bound on the default worker count for the bevy_ecs task pool when no plugin or env var raises it. One worker per main-stage band (input / systems / layout / render). The effective default is default_thread_budget = min(available_parallelism, LUMEN_DEFAULT_THREADS), so a 24-core box does not spawn a 24-wide pool for a UI that never saturates four workers.

Traits§

Plugin
Plugin trait registered via App::add_plugin.
PluginMetadata
Type-erased plugin metadata recorded by App::add_plugin.

Functions§

default_thread_budget
Effective default worker budget: LUMEN_DEFAULT_THREADS capped to the machine’s available parallelism. Falls back to 1 when parallelism is unknown. The LUMEN_THREADS env var (read in [ensure_task_pool]) and lumen.toml [runtime] threads still override this.
mark_process_start
Record the process-start instant. Idempotent - only the first call wins, so calling it as the first statement of main captures the earliest reachable moment. A no-op if already set.
process_start
The process-start instant recorded by mark_process_start, if any.