Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mitsuhiko/procspawn
like thread::spawn but for processes
https://github.com/mitsuhiko/procspawn
Last synced: 14 days ago
JSON representation
like thread::spawn but for processes
- Host: GitHub
- URL: https://github.com/mitsuhiko/procspawn
- Owner: mitsuhiko
- License: apache-2.0
- Created: 2020-02-07T09:09:24.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-08-06T21:25:36.000Z (3 months ago)
- Last Synced: 2024-10-13T01:32:55.055Z (about 1 month ago)
- Language: Rust
- Homepage: https://docs.rs/procspawn
- Size: 205 KB
- Stars: 149
- Watchers: 6
- Forks: 16
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# procspawn
[![Build Status](https://github.com/mitsuhiko/procspawn/workflows/Tests/badge.svg?branch=master)](https://github.com/mitsuhiko/procspawn/actions?query=workflow%3ATests)
[![Crates.io](https://img.shields.io/crates/d/procspawn.svg)](https://crates.io/crates/procspawn)
[![Documentation](https://docs.rs/procspawn/badge.svg)](https://docs.rs/procspawn)
[![rustc 1.65.0](https://img.shields.io/badge/rust-1.70%2B-orange.svg)](https://img.shields.io/badge/rust-1.70%2B-orange.svg)This crate provides the ability to spawn processes with a function similar
to `thread::spawn`. Instead of closures it passes [`serde`](https://serde.rs/)
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.```rust
procspawn::init();
```Step 2: now you can start spawning functions:
```rust
let data = vec![1, 2, 3, 4];
let handle = procspawn::spawn(data, |data| {
println!("Received data {:?}", &data);
data.into_iter().sum::()
});
let result = handle.join().unwrap();
```## License and Links
- [Documentation](https://docs.rs/procspawn/)
- [Issue Tracker](https://github.com/mitsuhiko/procspawn/issues)
- [Examples](https://github.com/mitsuhiko/procspawn/tree/master/examples)
- License: [Apache-2.0](https://github.com/mitsuhiko/procspawn/blob/master/LICENSE-APACHE)