Crates.io | omango |
lib.rs | omango |
version | 0.2.6 |
source | src |
created_at | 2022-05-24 08:49:37.84732 |
updated_at | 2024-09-11 10:22:44.543311 |
description | Concurrency collections |
homepage | https://github.com/tqtrungse/omango |
repository | https://github.com/tqtrungse/omango |
max_upload_size | |
id | 592619 |
size | 351,188 |
This is a concurrency collection.
Support lock-free SPSC and MPMC queue (bounded and unbounded). 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 ).
Support Golang WaitGroup
waits for a collection of threads to finish.
Support Single Flight
multiplexing threads that have the same work and
only one represent thread will run and returns response for all waiting threads.
Support Single Source
provide mechanism to synthesize response from multiple
sources.
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.
Performance is better.
Supported unbounded queues (SPSC + MPMC).
Can use recv
to get remaining items when the queue was closed.
Add this to your Cargo.toml
:
[dependencies]
omango = "0.2.6"
The minimum supported Rust version is 1.57
.
Tests were performed on an Intel Core I7 with 4 cores running Windows 11 and M1 with 8 cores running macOS BigSur 11.3.
The crate is licensed under the terms of the MIT license. See LICENSE for more information.