Skip to main content

spawn_background_thread

Function spawn_background_thread 

pub fn spawn_background_thread<T, F>(
    name: impl Into<String>,
    body: F,
) -> Result<JoinHandle<T>, Error>
where F: FnOnce() -> T + Send + 'static, T: Send + 'static,
Expand description

spawn_thread for work a person does not wait on frame by frame — rasterising pages ahead of a scroll, decoding, indexing — that must never take a CPU from the thread drawing the window. On Linux the thread runs BACKGROUND_NICE steps below its spawner, so on a machine with one or two slow cores the UI thread is scheduled first and the work fills the time it leaves; elsewhere it is an ordinary thread.

§Errors

As spawn_thread.