Skip to main content

Executor

Trait Executor 

Source
pub trait Executor:
    Send
    + Sync
    + 'static {
    // Required methods
    fn spawn(&self, name: &'static str, job: Job) -> Result<(), Unsupported>;
    fn wake_at(&self, deadline: Instant, wake: WakeHandle);
    fn park(&self, deadline: Instant);

    // Provided method
    fn now(&self) -> Instant { ... }
}

Required Methods§

Source

fn spawn(&self, name: &'static str, job: Job) -> Result<(), Unsupported>

Run job off the calling thread. name identifies the work in logs.

Implementations must not run job before returning: callers may hold locks the job also takes.

§Errors

Returns Unsupported when this host cannot run background work.

Source

fn wake_at(&self, deadline: Instant, wake: WakeHandle)

Source

fn park(&self, deadline: Instant)

Block until background work may have made progress, or until deadline. For synchronous drivers only (headless capture, tests) — never call this on a live UI thread.

Provided Methods§

Source

fn now(&self) -> Instant

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§