pub fn spawn<A: Serialize + DeserializeOwned, R: Serialize + DeserializeOwned>(
args: A,
f: fn(A) -> R,
) -> JoinHandle<R>Expand description
Spawn a new process to run a function with some payload.
// call this early in your main() function. This is where all spawned
// functions will be invoked.
procspawn::init();
let data = vec![1, 2, 3, 4];
let handle = procspawn::spawn(data, |data| {
println!("Received data {:?}", &data);
data.into_iter().sum::<i64>()
});
let result = handle.join().unwrap();