pub fn spawn_cpu<F: FnOnce() -> Result<R> + Send + 'static, R: Send + 'static>(
func: F,
) -> impl Future<Output = Result<R>>
Expand description
Spawn a CPU intensive task
This task will be put onto a thread pool dedicated for CPU-intensive work This keeps the tokio thread pool free so that we can always be ready to service cheap I/O & control requests.
This can also be used to convert a big chunk of synchronous work into a future so that it can be run in parallel with something like StreamExt::buffered()