pub trait CpuPool: Send + Sync {
// Required method
fn spawn_raw(
&self,
task: Box<dyn FnOnce() + Send + 'static>,
) -> Pin<Box<dyn Future<Output = Result<(), CoreError>> + Send + 'static>>;
}Expand description
Dyn-compatible interface for a CPU-bound thread pool.
Use the blanket CpuPoolExt::spawn method for ergonomic, generic usage.
Implement only CpuPool::spawn_raw in concrete types.
Required Methods§
Sourcefn spawn_raw(
&self,
task: Box<dyn FnOnce() + Send + 'static>,
) -> Pin<Box<dyn Future<Output = Result<(), CoreError>> + Send + 'static>>
fn spawn_raw( &self, task: Box<dyn FnOnce() + Send + 'static>, ) -> Pin<Box<dyn Future<Output = Result<(), CoreError>> + Send + 'static>>
Spawn a task on the pool and return a future that resolves once the task
finishes. The future does not borrow self; the task is enqueued
immediately when spawn_raw is called.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".