3 unstable releases
new 0.2.4 | Apr 20, 2024 |
---|---|
0.2.2 | Mar 28, 2024 |
0.1.4 | Jul 13, 2022 |
0.1.3 |
|
#152 in Concurrency
415 downloads per month
175KB
1.5K
SLoC
Omango
This is a concurrency library.
The crate provides a lock-free bounded and unbounded single-producer-single-consumer channel and
multi-producer-multi-consumer channel.
The queues are simple, lightweight, fast and safe in multithreading environment.
It is faster than std::mpsc::sync_channel
and other open source's bounded queue (
ringbuf,
rtrb,
flume,
crossbeam-channel
).
Table of Contents
Introduction
Both SPSC
and MPMC
queue are implemented based on pseudocode of Dmitry Vyukov.
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.
Both SPSC
and MPMC
queue can be used as channels.
Compared with version 0.1.*
-
Performance is better.
-
Supported unbounded queues (SPSC + MPMC).
-
Can use
recv
to get remaining items when the queue was closed.
Usage
Add this to your Cargo.toml
:
[dependencies]
omango = "0.2.4"
Compatibility
The minimum supported Rust version is 1.57
.
Benchmarks
Tests were performed on an Intel Core I5 with 4 cores running Windows 10 and M1 with 8 cores running macOS BigSur 11.3.
License
The crate is licensed under the terms of the MIT license. See LICENSE for more information.
Reference
Dependencies
~0.4–10MB
~65K SLoC