mp2c
Multi producer multi polling consumer
What is mp2c?
MP2C is a data structure that enables multiple producers/publishers to send messages to multiple consumers/subscribers.
The async mp2c data structure is called a Carousel.
What do you mean by messages?
A message in mp2c context is a vector of u8. It's up to the producers/ consumers to marshall and unmarshall these messages as they best see fit.
Is mp2c thread safe?
Yes.
How can multiple producers(threads) send messages to a mp2c Carousel?
Cloning a mp2c::asynch::Carousel creates a clone of the underlying std::sync::Sender and every invocation of Carousel::put will send messages to the consumers.
Does mp2c support async message pub?
mp2c::asynch::Carousel supports full async behavior. All messages put on the Carousel are asynchronously sent to the consumers.
Is there a memory overhead?
Yes. In the spirit of don't communicate by sharing memory, share memory by communicating, all messages are cloned as many times as the count of mp2c::asynch::Consumers.
Multi producer multi consumer example
use ;
;
;
let mut v: = Vecnew;
v.push;
v.push;
let c = new;
for _ in 1..10
What's next?
Message id
Add a message id to each message being put on the data carousel.
Release history
v0.1.2
Make consumer mutable
v0.1.1
Updated README with example.
v0.1.0
Initial release.