This is a concurrency library.
The crate provides a lock-free bounded single-producer-single-consumer channel and
multi-producer-multi-consumer channel.
The channels are simple, lightweight, fast and safe in multithreading environment.
It is faster than std::mpsc::sync_channel
and other open source's bounded queue (multiqueue, flume, crossbeam-channel).
Both SPSC
and MPMC
channel are implemented based on pseudocode of Dmitry Vyukov's queue.
The implementation way is exactly the same. But there are still some differences between them about wait-retry and blocking.
MPMC
is high contention multithreading environment. If the retry is continuous and immediate, the CPU cache coherence
will be increased rapidly and decrease performance. Therefore, we must wait then retry.
However, this thing is unsuitable in SPSC
is lower contention multithreading environment (Just 2 threads).
In SPSC
, the immediate retry still guarantees performance.
The blocking management and optimization in MPMC
is more complex than SPSC
in spite of the same implementation idea.
Both SPSC
and MPMC
channel can be used as queues.
Add this to your Cargo.toml
:
toml
[dependencies]
omango = "0.1.0"
The minimum supported Rust version is 1.49.
The crate is licensed under the terms of the MIT license. See LICENSE for more information.
This product includes copies and modifications of software developed by third parties:
src/backoff.rs includes copies and modifications of code from original file, licensed under the MIT License and the Apache License, Version 2.0.
src/cache_padded.rs includes copies and modifications of code from original file, licensed under the MIT License and the Apache License, Version 2.0.
See the source code files for more details.
The third party licenses can be found in here.