pub trait TaskProvider:
Clone
+ Send
+ Sync
+ 'static {
type JoinHandle: Future<Output = Result<(), JoinError>> + Send + Sync + 'static;
// Required methods
fn spawn_task<F>(&self, name: &str, future: F) -> Self::JoinHandle
where F: Future<Output = ()> + Send + 'static;
fn yield_now(&self) -> impl Future<Output = ()> + Send;
}Expand description
Provider for spawning tasks.
This trait abstracts task spawning to enable both real tokio tasks
and simulation-controlled task scheduling. The simulation runtime
runs on a single OS thread, but the spawned futures are Send-bounded
so customer call graphs can use Arc<RwLock<…>>, DashMap, and other
Send + Sync primitives without contortion.
Required Associated Types§
Sourcetype JoinHandle: Future<Output = Result<(), JoinError>> + Send + Sync + 'static
type JoinHandle: Future<Output = Result<(), JoinError>> + Send + Sync + 'static
Future returned by Self::spawn_task.
Resolves with Ok(()) on normal completion, or a JoinError if the
task was cancelled or panicked.
Required Methods§
Sourcefn spawn_task<F>(&self, name: &str, future: F) -> Self::JoinHandle
fn spawn_task<F>(&self, name: &str, future: F) -> Self::JoinHandle
Spawn a named task.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
Source§impl TaskProvider for TokioTaskProvider
Available on crate feature tokio-providers only.
impl TaskProvider for TokioTaskProvider
Available on crate feature
tokio-providers only.