#ipc #shared

ipmpsc

Inter-process Multiple Producer, Single Consumer Channels

4 releases (2 breaking)

new 0.3.1 Oct 15, 2020
0.3.0 Jul 13, 2020
0.2.0 Aug 6, 2019
0.1.0 Jun 18, 2019

#54 in Unix APIs

Download history 35/week @ 2020-06-28 11/week @ 2020-07-05 73/week @ 2020-07-12 35/week @ 2020-07-19 102/week @ 2020-07-26 40/week @ 2020-08-02 85/week @ 2020-08-09 188/week @ 2020-08-16 281/week @ 2020-08-23 48/week @ 2020-08-30 58/week @ 2020-09-06 164/week @ 2020-09-13 117/week @ 2020-09-20 173/week @ 2020-09-27 72/week @ 2020-10-04 103/week @ 2020-10-11

469 downloads per month

MIT license

29KB
518 lines

ipmpsc

Inter-Process Multiple Producer, Single Consumer Channels for Rust

Crates.io Build Status MIT licensed

Summary

This library provides a type-safe, high-performance inter-process channel implementation based on a shared memory ring buffer. It uses bincode for (de)serialization, including zero-copy deserialization, making it ideal for messages with large &str or &[u8] fields. And it has a name that rolls right off the tongue.

Examples

The examples directory contains a sender and receiver pair, which you can run in separate terminals like so:

cargo run --example ipmpsc-receive -- --zero-copy /tmp/ipmpsc
cargo run --example ipmpsc-send -- /tmp/ipmpsc

Type some lines of text into the sender and observe that they are printed by the receiver. You can also run additional senders from other terminals -- the receiver will receive messages from any of them.

Performance

ipmpsc::Receiver::zero_copy_context, used in combination with serde_bytes, is capable of supporting very high bandwidth, low latency transfers (e.g. uncompressed video frames).

Security

The ring buffer is backed by a shared memory-mapped file, which means any process with access to that file can read from or write to it depending on its privileges. This may or may not be acceptable depending on the security needs of your application and the environment in which it runs.

Platform Support

The current implementation should work on any POSIX-compatible OS. It's been tested on Linux and Android. Windows support is planned but has not been started yet.

Similar Projects

ipc-channel - mature and robust IPC channels. Does not yet support Android, multiple simultaneous senders, or zero-copy deserialization.

shared_memory - low-level, cross-platform shared memory support. May be used as the basis for a ring-buffer based channel, but does not yet support Android.

Dependencies

~1.1–1.9MB
~40K SLoC