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 |
#179 in Encoding
4,821 downloads per month
Used in 4 crates
82KB
1.5K
SLoC
procspawn
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();
License and Links
- Documentation
- Issue Tracker
- Examples
- License: Apache-2.0
Dependencies
~5–38MB
~585K SLoC