1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! Promisqs (pronounced "promiscuous") cross-platform, shared memory,
//! multi-producer, multi-consumer queue implementation.
//!
//! The main use-case for this library is for ultra low latency inter-process communication (IPC),
//! significantly faster than you would get using any other means, like sockets, UNIX sockets (named pipes
//! on windows) and even things like DBUS on Linux.
//! For smaller sized types (a few kB or smaller), Promisqs can easily achieve a latency of a few tenths of a micro-second!
//!
//! The queue implementation [`ShmemQueue`](queue/struct.ShmemQueue.html) is generic, allowing most primitive types, and any type that implements the [`FromBytes`](https://docs.rs/zerocopy/latest/zerocopy/trait.FromBytes.html),
//! [`IntoBytes`](https://docs.rs/zerocopy/latest/zerocopy/trait.IntoBytes.html), and [`Immutable`](https://docs.rs/zerocopy/latest/zerocopy/trait.Immutable.html) traits, to be used with the queue.
//!
//! Note that these traits cannot be implemented directly for a type, and must be directly derived, due to safety concerns.
//! Most primitive types and other fixed size types, like enums, arrays etc.
//! can be used with the queue. Dynamic types like strings or vectors cannot.
//!
//! **NOTE** - In order to implement these traits for your type, you must add [`zerocopy`](https://docs.rs/zerocopy/latest/zerocopy/) as a dependency to your crate.
//!
//! # Producer Example
//!
//! ```
//! use promisqs::{ShmemQueue, IntoBytes, FromBytes, Immutable};
//!
//! // Define a struct that derives `zerocopy` traits,
//! // so that we can use it with promisqs queues
//! #[derive(Debug, Clone, IntoBytes, FromBytes, Immutable, PartialEq)]
//! pub struct Message {
//! id: u8,
//! address: [u8; 4],
//! payload: [u8; 4],
//! }
//!
//! let mut q = ShmemQueue::<Message>::create("flink.map", 1).unwrap();
//!
//! let msg = Message {
//! id: 0x0,
//! address: [0xc8, 0xa8, 0x1, 0x1],
//! payload: [01, 0x2, 0x3, 0x4],
//! };
//!
//! q.push(&msg).unwrap();
//!
//! # drop(q);
//! # std::thread::sleep(std::time::Duration::from_millis(100));
//! ```
//! # Consumer Example (different process)
//! ```
//! use promisqs::{ShmemQueue, IntoBytes, FromBytes, Immutable};
//!
//! #[derive(Debug, Clone, IntoBytes, FromBytes, Immutable, PartialEq)]
//! pub struct Message {
//! id: u8,
//! address: [u8; 4],
//! payload: [u8; 4],
//! }
//!
//! # let _q = ShmemQueue::<Message>::create("flink.map", 1).unwrap();
//! let mut q = ShmemQueue::<Message>::open("flink.map").unwrap();
//!
//! let expected_msg = Message {
//! id: 0x0,
//! address: [0xc8, 0xa8, 0x1, 0x1],
//! payload: [01, 0x2, 0x3, 0x4],
//! };
//! # q.push(&expected_msg).unwrap();
//!
//! assert_eq!(q.pop().unwrap(), expected_msg);
//!
//! # drop(_q);
//! # drop(q);
//! # std::thread::sleep(std::time::Duration::from_millis(100));
//! ```
pub use PromisqsError;
pub use ;
pub use ;