Function rustler::thread::spawn
[−]
[src]
pub fn spawn<'a, S, F>(env: NifEnv<'a>, thread_fn: F) where
F: for<'b> FnOnce(NifEnv<'b>) -> NifTerm<'b> + Send + UnwindSafe + 'static,
S: JobSpawner,
Implements threaded NIFs.
This spawns a thread that calls the given closure thread_fn
. When the closure returns, the
thread sends its return value back to the calling process. If the closure panics, an {error, Reason}
tuple is sent instead.
Note that the thread creates a new NifEnv
and passes it to the closure, so the closure
runs under a separate environment, not under env
.