1# Crossbeam Channel 2 3[![Build Status](https://travis-ci.org/crossbeam-rs/crossbeam.svg?branch=master)]( 4https://travis-ci.org/crossbeam-rs/crossbeam) 5[![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)]( 6https://github.com/crossbeam-rs/crossbeam-channel) 7[![Cargo](https://img.shields.io/crates/v/crossbeam-channel.svg)]( 8https://crates.io/crates/crossbeam-channel) 9[![Documentation](https://docs.rs/crossbeam-channel/badge.svg)]( 10https://docs.rs/crossbeam-channel) 11[![Rust 1.28+](https://img.shields.io/badge/rust-1.28+-lightgray.svg)]( 12https://www.rust-lang.org) 13[![chat](https://img.shields.io/discord/569610676205781012.svg?logo=discord)](https://discord.gg/BBYwKq) 14 15This crate provides multi-producer multi-consumer channels for message passing. 16It is an alternative to [`std::sync::mpsc`] with more features and better performance. 17 18Some highlights: 19 20* [`Sender`]s and [`Receiver`]s can be cloned and shared among threads. 21* Two main kinds of channels are [`bounded`] and [`unbounded`]. 22* Convenient extra channels like [`after`], [`never`], and [`tick`]. 23* The [`select!`] macro can block on multiple channel operations. 24* [`Select`] can select over a dynamically built list of channel operations. 25* Channels use locks very sparingly for maximum [performance](benchmarks). 26 27[`std::sync::mpsc`]: https://doc.rust-lang.org/std/sync/mpsc/index.html 28[`Sender`]: https://docs.rs/crossbeam-channel/*/crossbeam_channel/struct.Sender.html 29[`Receiver`]: https://docs.rs/crossbeam-channel/*/crossbeam_channel/struct.Receiver.html 30[`bounded`]: https://docs.rs/crossbeam-channel/*/crossbeam_channel/fn.bounded.html 31[`unbounded`]: https://docs.rs/crossbeam-channel/*/crossbeam_channel/fn.unbounded.html 32[`after`]: https://docs.rs/crossbeam-channel/*/crossbeam_channel/fn.after.html 33[`never`]: https://docs.rs/crossbeam-channel/*/crossbeam_channel/fn.never.html 34[`tick`]: https://docs.rs/crossbeam-channel/*/crossbeam_channel/fn.tick.html 35[`select!`]: https://docs.rs/crossbeam-channel/*/crossbeam_channel/macro.select.html 36[`Select`]: https://docs.rs/crossbeam-channel/*/crossbeam_channel/struct.Select.html 37 38## Usage 39 40Add this to your `Cargo.toml`: 41 42```toml 43[dependencies] 44crossbeam-channel = "0.4" 45``` 46 47Next, add this to your crate: 48 49```rust 50#[macro_use] 51extern crate crossbeam_channel; 52``` 53 54## Compatibility 55 56The minimum supported Rust version is 1.28. Any change to this is considered a breaking change. 57 58## License 59 60Licensed under either of 61 62 * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) 63 * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) 64 65at your option. 66 67#### Contribution 68 69Unless you explicitly state otherwise, any contribution intentionally submitted 70for inclusion in the work by you, as defined in the Apache-2.0 license, shall be 71dual licensed as above, without any additional terms or conditions. 72 73#### Third party software 74 75This product includes copies and modifications of software developed by third parties: 76 77* [examples/matching.rs](examples/matching.rs) includes 78 [matching.go](http://www.nada.kth.se/~snilsson/concurrency/src/matching.go) by Stefan Nilsson, 79 licensed under Creative Commons Attribution 3.0 Unported License. 80 81* [src/flavors/array.rs](src/flavors/array.rs) is based on 82 [Bounded MPMC queue](http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue) 83 by Dmitry Vyukov, licensed under the Simplified BSD License and the Apache License, Version 2.0. 84 85* [tests/mpsc.rs](tests/mpsc.rs) includes modifications of code from The Rust Programming Language, 86 licensed under the MIT License and the Apache License, Version 2.0. 87 88* [tests/golang.rs](tests/golang.rs) is based on code from The Go Programming Language, licensed 89 under the 3-Clause BSD License. 90 91See the source code files for more details. 92 93Copies of third party licenses can be found in [LICENSE-THIRD-PARTY](LICENSE-THIRD-PARTY). 94