Skip to main content

cpu

Function cpu 

pub fn cpu<R, F>(work: F) -> CpuTask<R> ⓘ
where F: FnOnce() -> R + Send + 'static, R: Send + 'static,
Expand description

Run work on the cpu_pool and await its result.

Hashing, chunking, compression, image decoding and index building belong here: on an async worker they stall every task behind them, and on a blocking pool they compete with blocking I/O for threads sized for waiting, not computing.

In a browser the work runs on the page thread as an app task, after the caller yields.