pub trait Dispatcher:
Send
+ Sync
+ 'static {
// Required methods
fn dispatch_on_main_thread(&self, task: Runnable);
fn dispatch_background(&self, task: Runnable, priority: DispatchPriority);
fn dispatch_after(&self, delay: Duration, task: Runnable);
fn wake(&self, window: Option<AppWindowId>);
fn exec_capabilities(&self) -> ExecCapabilities;
}Expand description
Portable execution surface provided by the runner.
This is a semantic contract (ADR 0175). Implementations live in platform runners and must:
- Preserve the main-thread mutation invariant (UI/runtime state is main-thread only).
- Keep the servicing thread/queue mapping stable for the lifetime of the process.
- Provide a
wake()that advances the runner to the next driver boundary.
Required Methods§
Sourcefn dispatch_on_main_thread(&self, task: Runnable)
fn dispatch_on_main_thread(&self, task: Runnable)
Schedule work to run on the UI/main thread.
Sourcefn dispatch_background(&self, task: Runnable, priority: DispatchPriority)
fn dispatch_background(&self, task: Runnable, priority: DispatchPriority)
Schedule work to run off the UI thread where available.
On constrained platforms (e.g. wasm without threads) this may be implemented as best-effort cooperative execution, but must still preserve the main-thread mutation invariant.
Sourcefn dispatch_after(&self, delay: Duration, task: Runnable)
fn dispatch_after(&self, delay: Duration, task: Runnable)
Schedule delayed work.
Implementations must share the same timer substrate/time base as effect timers to avoid split-brain scheduling (ADR 0175 / ADR 0034).
Sourcefn wake(&self, window: Option<AppWindowId>)
fn wake(&self, window: Option<AppWindowId>)
Request that the runner reaches the next driver boundary promptly.
Runners should coalesce repeated calls and may use window as a hint for multi-window
implementations.
Sourcefn exec_capabilities(&self) -> ExecCapabilities
fn exec_capabilities(&self) -> ExecCapabilities
Execution capabilities exposed by this dispatcher implementation.