pub trait TaskProvider: Clone {
// Required methods
fn spawn_task<F>(&self, name: &str, future: F) -> JoinHandle<()>
where F: Future<Output = ()> + 'static;
fn yield_now<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
}Expand description
Provider for spawning local tasks in single-threaded context.
This trait abstracts task spawning to enable both real tokio tasks and simulation-controlled task scheduling while maintaining deterministic execution in single-threaded environments.
Required Methods§
Sourcefn spawn_task<F>(&self, name: &str, future: F) -> JoinHandle<()>
fn spawn_task<F>(&self, name: &str, future: F) -> JoinHandle<()>
Spawn a named task that runs on the current thread.
The task will be executed using spawn_local to maintain single-threaded execution guarantees required for simulation.
Sourcefn yield_now<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn yield_now<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Yield control to allow other tasks to run.
This is equivalent to tokio::task::yield_now() but abstracted to enable simulation control and deterministic behavior.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.