commonware_runtime

Trait Spawner

source
pub trait Spawner:
    Clone
    + Send
    + Sync
    + 'static {
    // Required method
    fn spawn<F, T>(&self, label: &str, f: F) -> Handle<T> 
       where F: Future<Output = T> + Send + 'static,
             T: Send + 'static;
}
Expand description

Interface that any task scheduler must implement to spawn sub-tasks in a given root task.

Required Methods§

source

fn spawn<F, T>(&self, label: &str, f: F) -> Handle<T>
where F: Future<Output = T> + Send + 'static, T: Send + 'static,

Enqueues a task to be executed.

Label can be used to track how many instances of a specific type of task have been spawned or are running concurrently (and is appened to all metrics). Label is automatially appended to the parent task labels (i.e. spawning “fun” from “have” will be labeled “have_fun”).

Unlike a future, a spawned task will start executing immediately (even if the caller does not await the handle).

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Spawner for commonware_runtime::deterministic::Context

source§

impl Spawner for commonware_runtime::tokio::Context