[][src]Crate bondi

Bondi

This is built to provide an inter-process mechanism to communicate between different parties.

It allows a Writer send a message that can be read by multiple Reader s concurrently. The role of Bondi is to sync these operations, while keeping things fast.

It's worth mentioning that the current implementation blocks on slow readers. It may be preffered to drop slow consumers, when they cannot keep up with the writer's speed. This variant will likely be the one introduced in the future, to enhance performance. However, this will mean that not every consumer will necessarily get all messages, but only the fast enough ones.

A Simple example

// initialize a writer and two readers
// send 100 `Message`s, and receive them from different threads
#[derive(Debug, Clone)]
struct Message(usize);

use bondi::Bondi;

fn main() {
    let bondi = Bondi::new(100);
    let writer = bondi.get_tx().unwrap();
    let reader = bondi.get_rx().unwrap();
    let reader2 = bondi.get_rx().unwrap();

    std::thread::spawn(move || {
        for i in 0..100 {
            writer.write(Message(i));
        }
    });

    std::thread::spawn(move || {
        for i in 0..100 {
            reader.read();
        }
    });

    std::thread::spawn(move || {
        for i in 0..100 {
            reader2.read();
        }
    }).join().unwrap();
}

Modules

errors
reader
ring
writer

Structs

Bondi