Skip to main content

Waker

Type Alias Waker 

Source
pub type Waker = Box<dyn Fn() + Send + Sync>;
Expand description

Owns the engine thread and exposes a synchronous facade.

Drop semantics: dropping the runtime closes the command channel, which causes the engine thread to exit its loop and drop the engine. The destructor joins the thread. Called after a job is queued, to nudge a host loop that is asleep.

An mpsc send is invisible to a platform run loop, so a MainThreadDispatcher host cannot block waiting for work — it has to wake periodically and poll, trading idle CPU against how long a queued job sits. With a waker installed the host can sleep properly and be woken the moment a job lands, which removes both costs.

Must be safe to call from any thread.

Aliased Type§

pub struct Waker(/* private fields */);