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