Skip to main content

spawn

Function spawn 

Source
pub fn spawn<F, T>(f: F) -> Result<JoinHandle<T>>
where F: FnOnce() -> T + Send + 'static, T: Send + 'static,
Expand description

Spawn an OS thread that is bound to this app (ADR-314).

Thin wrapper around Builder::new().spawn: same binding semantics, default name and stack size. Prefer Builder when you need a name or a custom stack.

§Errors

The OS could not create a thread; the closure never runs.

§Examples

let handle = node_app_sdk_rust::thread::spawn(|| 6 * 7).unwrap();
assert_eq!(handle.join().unwrap(), 42);