18 releases (1 stable)

1.0.0 Sep 11, 2023
0.10.3 Aug 31, 2023
0.10.2 Jan 26, 2023
0.10.1 Jan 15, 2022
0.8.4 Feb 28, 2020

#210 in Encoding

Download history 1908/week @ 2024-02-03 3618/week @ 2024-02-10 3198/week @ 2024-02-17 3359/week @ 2024-02-24 3044/week @ 2024-03-02 2209/week @ 2024-03-09 1421/week @ 2024-03-16 2210/week @ 2024-03-23 2718/week @ 2024-03-30 2647/week @ 2024-04-06 3327/week @ 2024-04-13 2705/week @ 2024-04-20 2977/week @ 2024-04-27 2535/week @ 2024-05-04 1203/week @ 2024-05-11 2083/week @ 2024-05-18

9,286 downloads per month
Used in 3 crates

MIT/Apache

82KB
1.5K SLoC

procspawn

Build Status Crates.io Documentation rustc 1.65.0

This crate provides the ability to spawn processes with a function similar to thread::spawn. Instead of closures it passes serde serializable objects. The return value from the spawned closure also must be serializable and can then be retrieved from the returned join handle.

If the spawned functiom causes a panic it will also be serialized across the process boundaries.

Example

Step 1: invoke procspawn::init at a point early in your program (somewhere at the beginning of the main function). Whatever happens before that point also happens in your spawned functions.

procspawn::init();

Step 2: now you can start spawning functions:

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();

Dependencies

~7–18MB
~286K SLoC