Trait Executor
pub trait Executor:
Send
+ Sync
+ 'static {
// Required methods
fn spawn(
&self,
name: &'static str,
job: Box<dyn FnOnce() + Send>,
) -> Result<(), Unsupported>;
fn wake_at(&self, deadline: Instant, wake: WakeHandle);
fn park(&self, deadline: Instant);
// Provided method
fn now(&self) -> Instant { ... }
}Expand description
How a host runs background work and timers.
Required Methods§
fn spawn(
&self,
name: &'static str,
job: Box<dyn FnOnce() + Send>,
) -> Result<(), Unsupported>
fn spawn( &self, name: &'static str, job: Box<dyn FnOnce() + Send>, ) -> 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.
fn wake_at(&self, deadline: Instant, wake: WakeHandle)
fn wake_at(&self, deadline: Instant, wake: WakeHandle)
Call WakeHandle::wake on wake once now reaches
deadline. A deadline already in the past wakes promptly.