A blazingly fast multi-producer, single-consumer channel (now with select
support!).
```rust let (tx, rx) = flume::unbounded();
thread::spawn(move || { for i in 0..10 { tx.send(i); } });
let received = rx .iter() .sum();
assert_eq!((0..10).sum(), received); ```
Send
and may be clonedstd::sync::mpsc
select
interface (see [examples/select.rs])To use Flume, place the following line under the [dependencies]
section in your Cargo.toml
:
flume = "x.y"
Flume has no unsafe
code, so you can be sure that it's not going to leave you with nasal demons.
Flume is implemented in just a few hundred lines of code and has very few dependencies. This makes it extremely fast to compile.
Flume is considerably faster than std
's mpsc
and often outperforms crossbeam_channel
.
The following benchmarks were performed on a quad-core (8 logical cores) 2.8 GHz Ryzen 7 CPU running the standard Arch Linux kernel.
```
create-flume time: [124.53 ns] create-crossbeam time: [175.76 ns] create-std time: [47.773 ns] <--- Fastest
oneshot-flume time: [147.49 ns] oneshot-crossbeam time: [326.60 ns] oneshot-std time: [64.348 ns] <--- Fastest
inout-flume time: [18.123 ns] <--- Fastest inout-crossbeam time: [56.132 ns] inout-std time: [42.288 ns]
hydra-32t-1m-flume time: [98.227 us] <--- Fastest hydra-32t-1m-crossbeam time: [423.58 us] hydra-32t-1m-std time: [102.00 us]
hydra-32t-1000m-flume time: [1.6267 ms] <--- Fastest hydra-32t-1000m-crossbeam time: [3.6800 ms] hydra-32t-1000m-std time: [3.2338 ms]
hydra-1t-1000m-flume time: [89.608 us] hydra-1t-1000m-crossbeam time: [71.650 us] <--- Fastest hydra-1t-1000m-std time: [180.53 us]
hydra-4t-10000m-flume time: [2.7487 ms] <--- Fastest hydra-4t-10000m-crossbeam time: [3.2055 ms] hydra-4t-10000m-std time: [4.8473 ms] ```
Flume is licensed under either of:
Apache License 2.0, (http://www.apache.org/licenses/LICENSE-2.0)
MIT license (http://opensource.org/licenses/MIT)