pub struct Runtime { /* private fields */ }Implementations§
Source§impl Runtime
impl Runtime
Sourcepub fn spawner(&self) -> Spawner
pub fn spawner(&self) -> Spawner
Returns a weak capability for submitting work to this runtime.
Sourcepub fn spawn<F, T>(
&self,
priority: Priority,
future: F,
) -> Result<Task<T>, SpawnError>
pub fn spawn<F, T>( &self, priority: Priority, future: F, ) -> Result<Task<T>, SpawnError>
Submits a task to one priority queue.
§Errors
Returns SpawnError::Closed after shutdown begins.
A successful return means the task was admitted into the runtime’s lifecycle. A concurrent forced or timed shutdown may cancel it before its first poll; graceful shutdown still waits for it to reach a terminal state.
Sourcepub fn stats(&self) -> RuntimeStats
pub fn stats(&self) -> RuntimeStats
Returns a relaxed snapshot of scheduler observability counters.
Sourcepub fn shutdown_graceful(self) -> Result<(), ShutdownError>
pub fn shutdown_graceful(self) -> Result<(), ShutdownError>
Rejects new tasks, drains every accepted task, and joins all workers.
§Errors
Returns ShutdownError::CalledFromWorker when invoked by this
runtime’s worker, or ShutdownError::WorkerPanicked if a joined
worker panicked.
Sourcepub fn shutdown_timeout(
self,
timeout: Duration,
) -> Result<ShutdownOutcome, ShutdownError>
pub fn shutdown_timeout( self, timeout: Duration, ) -> Result<ShutdownOutcome, ShutdownError>
Drains accepted tasks until timeout, then cancels the remainder.
§Errors
Returns ShutdownError::CalledFromWorker when invoked by this
runtime’s worker, or ShutdownError::WorkerPanicked if a joined
worker panicked.
Sourcepub fn shutdown_now(self) -> Result<(), ShutdownError>
pub fn shutdown_now(self) -> Result<(), ShutdownError>
Cancels remaining work and joins all workers.
§Errors
Returns ShutdownError::CalledFromWorker when invoked by this
runtime’s worker, or ShutdownError::WorkerPanicked if a joined
worker panicked.