Skip to main content

spawn_thread

Function spawn_thread 

Source
pub fn spawn_thread<F, T>(name: &'static str, f: F) -> Result<ThreadHandle<T>>
where F: FnOnce() -> T + Send + 'static, T: Send + 'static,
Expand description

Spawn f on a new OS thread named name.

The thread logs to the tracing subscriber that is the default where spawn_thread is called, or to the global default when none is set yet. A panic in f is logged at ERROR with name and returned by ThreadHandle::join.

ยงErrors

The OS error when the thread cannot be created.