crossbeam-channel 0.1.3

Multi-producer multi-consumer channels for message passing
Documentation

Multi-producer multi-consumer channels for message passing

Build Status License Cargo Documentation

Channels are concurrent FIFO queues used for passing messages between threads.

Crossbeam's channels are an alternative to the std::sync::mpsc channels provided by the standard library. They are an improvement in pretty much all aspects: ergonomics, flexibility, features, performance.

Read the original RFC that introduced these channels for more information on their design and implementation.

Usage

Add this to your Cargo.toml:

[dependencies]
crossbeam-channel = "0.1"

Next, add this to your crate:

extern crate crossbeam_channel;

Comparison with std::sync::mpsc

std::sync::mpsc crossbeam-channel
Unbounded channel constructor channel() unbounded()
Bounded channel constructor sync_channel(cap) bounded(cap)
Sender types Sender and SyncSender Sender
Receiver types Receiver Receiver
Sender implements Sync? No Yes
Receiver implements Sync? No Yes
Sender implements Clone? Yes Yes
Receiver implements Clone? No Yes
Sender operations try_send, send try_send, send, send_timeout
Receiver operations try_recv, recv, recv_timeout try_recv, recv, recv_timeout
Additional sender methods is_empty, len, capacity
Additional receiver methods iter, try_iter iter, try_iter, is_empty, len, capacity
Selection macro select! select_loop!
Select interface std::sync::mpsc::Select crossbeam_channel::Select
Select has a safe interface? No Yes
Select supports send operations? No Yes
Select can have a timeout? No Yes
Select can be non-blocking? No Yes

License

Licensed under the terms of MIT license and the Apache License (Version 2.0).

See LICENSE-MIT and LICENSE-APACHE for details.