Expand description
The shared render/event loop that drives a live App. Both the compiled
cn run runtime (run::start_runtime) and the interpreted cn debug path
(in the editor crate) pump the same loop; the only difference is the per-tick
hook the debug path threads through to run its DebugHook. Keeping the platform
event-pump and window-activation glue in one place means it is not duplicated
per entry point.
On macOS the world loop must pump the Cocoa run loop on the main thread each tick so AppKit (GLFW window creation, Metal pipeline compilation, event dispatch) can process its callbacks and Metal drawable presentation fires. On all other platforms a tight Rust loop is used, which is what the Vulkan / DirectX renderers expect.
Functions§
- install_
ctrlc_ handler - Install the process CTRL+C handler that cancels the app’s shutdown token, so the render loop exits cleanly. Panics if a handler is already installed; only one entry point installs it per process.
- run_
loop - Drive the world loop to completion. Each iteration: exit if the shutdown token
is cancelled; on macOS, when
pump_eventsis set (a window is present), drain the pending AppKit/CoreFoundation events so the window stays responsive and Metal drawable callbacks fire; run the per-tickon_tickhook; then step the world, stopping on Stop/Done.on_tickis where the interpreted debug path ticks its DebugHook; the runtime passes a no-op.