#multi-consumer #buffer #multi-producer #mpmc #producer-consumer

yanked mcmp

A small buffer thread safe with multiple producer and multiple consumer allowed

Uses old Rust 2015

0.1.4 May 19, 2018
0.1.3 May 19, 2018
0.1.2 May 19, 2018

#13 in #multi-producer

MIT license

11KB
263 lines

Do not use this crate for now ! This crate has big issues that are currently beeing solved !

Multi producer, multi consumer

The goal of this crate is to offer a simple, not too unefficent and thread-safe implementation of a multi producer and multi consumer buffer.

How to use it

There is only one thing to be aware of : it's that a consumer must be present before the buffer is full, if not the insert method will fail and return an error.

Example of usage

use mcmp::{Buffer, Producer, Consumer};

//Create a bufer of size 25.
let buffer = Buffer::new(25);
let producer = buffer.get_producer();
let consumer = buffer.get_consumer();

let _ = producer.insert(5);
let res = consumer.export().unwrap();

assert_eq!(res, 5);

To see more example, go to the test section in the code (at the end of lib.rs)

TODO

  • Add the option to change the buffer size after it has been created
  • Add non-blocking call to the buffer
  • Document all the function , the return and way to use it
  • The readme
  • ...

Contributing

Any contribution is welcome, just make a push request on the git repo ascosciated with this crate.

No runtime deps