pub trait Spawn {
type Handle<Output>: Future<Output = Result<Output, TaskError>> + Send + 'static
where Output: Send + 'static;
// Required method
fn spawn<FutureType>(
&self,
future: FutureType,
) -> Result<Self::Handle<FutureType::Output>, SpawnError>
where FutureType: Future + Send + 'static,
FutureType::Output: Send + 'static;
}Expand description
The common spawning contract for schedulers and their handles.
Required Associated Types§
Required Methods§
Sourcefn spawn<FutureType>(
&self,
future: FutureType,
) -> Result<Self::Handle<FutureType::Output>, SpawnError>
fn spawn<FutureType>( &self, future: FutureType, ) -> Result<Self::Handle<FutureType::Output>, SpawnError>
Register a task with this scheduler before making it runnable.
The returned handle owns the execution lifetime. Dropping it requests destruction after any active poll returns; moving it transfers ownership. Await it explicitly for completion, or cancel cooperatively and then await. If the scheduler is closed, the future is dropped without being polled.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".