19 releases (2 stable)

1.0.1 Aug 6, 2024
1.0.0 Sep 11, 2023
0.10.3 Aug 31, 2023
0.10.2 Jan 26, 2023
0.8.4 Feb 28, 2020

#167 in Encoding

Download history 2029/week @ 2024-07-17 2080/week @ 2024-07-24 1540/week @ 2024-07-31 1566/week @ 2024-08-07 1672/week @ 2024-08-14 1481/week @ 2024-08-21 1894/week @ 2024-08-28 1896/week @ 2024-09-04 1309/week @ 2024-09-11 1415/week @ 2024-09-18 1505/week @ 2024-09-25 1356/week @ 2024-10-02 1239/week @ 2024-10-09 1200/week @ 2024-10-16 1015/week @ 2024-10-23 1372/week @ 2024-10-30

5,186 downloads per month
Used in 4 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

~5–36MB
~589K SLoC