https://github.com/mersinvald/rust_shm_ipc
An example implementatation of synchronized queue for inter-process communication in shared memory
https://github.com/mersinvald/rust_shm_ipc
ipc linux posix pthread rust shm unix
Last synced: 5 months ago
JSON representation
An example implementatation of synchronized queue for inter-process communication in shared memory
- Host: GitHub
- URL: https://github.com/mersinvald/rust_shm_ipc
- Owner: mersinvald
- Created: 2017-02-17T16:18:06.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-02-17T16:34:19.000Z (about 8 years ago)
- Last Synced: 2024-12-01T12:44:07.611Z (5 months ago)
- Topics: ipc, linux, posix, pthread, rust, shm, unix
- Language: Rust
- Size: 7.81 KB
- Stars: 14
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SHM IPC example in Rust
[](https://travis-ci.org/mersinvald/rust_shm_ipc)This is an example implementatation of synchronized queue for inter-process communication in shared memory
for UNIX POSIX-complaint operating systems.Motivation is to try out rust in unix systems programming
### Goals:
- Safe IPC queue implementation
- Rusty wrappers for pthread sync primitives### Non-goals:
- Fast IPC queue
- Production-ready code
- Full-featured wrappers## Library support
Currently this example relies on master branch of rust-lang/libc because ofRequired bindings will be availible in version 0.2.21
## Usage example
``` rust
fn child(queue: Shm>) {
let pid = process::pid();
queue.push(pid).unwrap()
}fn main() {
// Create new queue in shm
let queue = Shm::new(Queue::pshared())
.unwrap();// Spawn processes
for _ in 0..10 {
process::spawn(|| {
child(queue.clone());
}).unwrap();
}while let Ok(Some(pid)) = queue.timed_pop(Duration::from_millis(10)) {
println!("PID {}", pid);
}
}
```