20 releases

0.3.0 Jan 3, 2024
0.2.1 Dec 15, 2023
0.1.16 Dec 11, 2023
0.1.12 Nov 28, 2023
0.1.7 Oct 20, 2023

#331 in Concurrency

Download history 11/week @ 2024-01-05 28/week @ 2024-01-12 1/week @ 2024-01-19 76/week @ 2024-01-26 91/week @ 2024-02-02 7/week @ 2024-02-09 101/week @ 2024-02-16 104/week @ 2024-02-23 73/week @ 2024-03-01 4/week @ 2024-03-08 29/week @ 2024-03-15 5/week @ 2024-03-22 12/week @ 2024-03-29 54/week @ 2024-04-05 101/week @ 2024-04-12 532/week @ 2024-04-19

699 downloads per month

MIT/Apache

46KB
890 lines

Loole

A safe async/sync multi-producer multi-consumer channel.

Github Actions Documentation Cargo License

fn main() {
    let (tx, rx) = loole::unbounded();

    std::thread::spawn(move || {
        for i in 0..10 {
            tx.send(i).unwrap();
        }
    });

    let mut sum = 0;
    while let Ok(i) = rx.recv() {
        sum += i;
    }

    assert_eq!(sum, (0..10).sum());
}

Producers can send and consumers can receive messages asynchronously or synchronously.

Usage

To use Loole, place the following line under the [dependencies] section in your Cargo.toml:

loole = "0.3.0"

Run Benchmarks

Benchmarks measure throughput, which is the number of messages sent and received per second, for messages of 264 bytes each.

To run benchmarks on your local machine, run the following command:

Prior to executing this command, ensure Node.js is installed.

cargo run --release -p benchmark

The above command will generate and update the benchmark images in the README.md file.

Benchmark Results

Benchmark results on:

OS: Ubuntu Linux 23.10, Kernel: 6.5.0-13

CPU: Intel Core i7-13700K (16/24-core/thread)

MPSC

Measures: Messages per second. (higher is better)

Messages size: 264 bytes.

MPSC: sync-sync MPSC: async-async MPSC: async-sync MPSC: sync-async

MPMC

Measures: Messages per second. (higher is better)

Messages size: 264 bytes.

MPMC: sync-sync MPMC: async-async MPMC: async-sync MPMC: sync-async

SPSC

Measures: Messages per second. (higher is better)

Messages size: 264 bytes.

SPSC: sync-sync SPSC: async-async SPSC: async-sync SPSC: sync-async

License

Loole is licensed under either of:

No runtime deps