pub fn spawn<F, T>(f: F) -> Result<JoinHandle<T>>Expand description
Spawn an OS thread that is bound to this app (ADR-314).
Everything std::thread::spawn does, plus the binding: the host
charges the new thread’s CPU and the memory it allocates to this app from
the moment it starts until it exits. The binding is released when the
closure returns — including when it panics, and including when the OS
refuses to start the thread (then there is nothing to release).
A host that predates ADR-314 exports no hooks: the closure still runs and nothing else happens.
§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);