spawn

Function spawn 

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

Helper for spawning a new thread with a beam.

ยงExample

let (hello, thread) = threadbeam::spawn(move |tx| {
    tx.send(String::from("Hello, world!"));
    // your code...
    String::from("Thread completed!")
});

assert_eq!(hello.as_deref(), Some("Hello, world!"));
assert_eq!(thread.join().ok().as_deref(), Some("Thread completed!"));