Skip to main content

Module executor

Module executor 

Source
Expand description

A single-threaded executor for a world’s async tasks. The async tasks a world runs, and the executor that drives them.

Some work a world starts is asynchronous — a GPU request that resolves once a device is ready, for instance — and crate::executor::LocalTasks is the pool that carries it. A world owns its tasks, so a task lasts as long as the world does, whatever call started it.

The executor is the ecosystem’s own, re-exported so a caller needs no futures dependency of their own. It is the one that fits a frame loop: it polls every task it holds until none can make progress and never blocks, and whoever drives the world pumps it — a thread’s tick loop before the tick, a host’s frame before the dispatch.

A spawned task is 'static, so what it lands has to be shared with the code that reads it: an Rc<RefCell<..>> slot that the tick drains, as a GPU request does.

§A world owns its tasks

The tasks live in the world they belong to, as a LocalTasks component, rather than in a LocalPool the caller keeps beside it. A task therefore lasts as long as the world does, whatever call started it, and no caller has to thread an executor through to the code that spawns. Every world the framework builds is given one at creation, before its setup runs; LocalTasks::pump gives one to a world that lacks it, which is how the host world, the one the caller made itself, gets its own.

Re-exports§

use std::future::Future; 🔒
use unlit_ecs::World; 🔒
use unlit_ecs::bundle; 🔒

Structs§

LocalPool
A single-threaded task pool for polling futures to completion.
LocalTasks
The async tasks a world runs, held as a component of that world.

Traits§

LocalSpawnExt
Extension trait for LocalSpawn.