pub trait BackgroundPool:
Send
+ Sync
+ 'static {
// Required method
fn spawn(
&self,
work: Box<dyn FnOnce() -> Result<Box<dyn Any + Send>, ProximaError> + Send>,
) -> BackgroundHandle<Box<dyn Any + Send>>;
}Expand description
Pluggable backend for cross-thread CPU-bound work.
The chain Runtime is per-core (!Send futures). When a Pipe
needs to do work that does migrate threads — image decoding,
model inference, parallel parsing, fork-join compute — it routes
through here. The pool runs on its own threads; the returned
handle is Send so the per-core caller can await it across the
chain-runtime / pool boundary.
Default: tokio::task::spawn_blocking (what Runtime::spawn_background_blocking
does in TokioPerCoreRuntime, feature tokio, when no pool is installed
with TokioPerCoreRuntime::with_background_pool — good for I/O-blocking
work). Alternative: RayonBackgroundPool (feature rayon) — work-
stealing across a fixed thread count, the right shape for
CPU-bound parallel compute.
Required Methods§
fn spawn( &self, work: Box<dyn FnOnce() -> Result<Box<dyn Any + Send>, ProximaError> + Send>, ) -> BackgroundHandle<Box<dyn Any + Send>>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".