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

#168 in Encoding

Download history 2371/week @ 2024-07-21 1660/week @ 2024-07-28 1510/week @ 2024-08-04 1811/week @ 2024-08-11 1200/week @ 2024-08-18 1677/week @ 2024-08-25 2120/week @ 2024-09-01 1493/week @ 2024-09-08 1124/week @ 2024-09-15 1481/week @ 2024-09-22 1478/week @ 2024-09-29 1430/week @ 2024-10-06 1179/week @ 2024-10-13 994/week @ 2024-10-20 1301/week @ 2024-10-27 1626/week @ 2024-11-03

5,124 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–35MB
~582K SLoC