1 //! Asynchronous channels. 2 //! 3 //! Like threads, concurrent tasks sometimes need to communicate with each 4 //! other. This module contains two basic abstractions for doing so: 5 //! 6 //! - [oneshot], a way of sending a single value from one task to another. 7 //! - [mpsc], a multi-producer, single-consumer channel for sending values 8 //! between tasks, analogous to the similarly-named structure in the standard 9 //! library. 10 //! 11 //! All items are only available when the `std` or `alloc` feature of this 12 //! library is activated, and it is activated by default. 13 14 #![cfg_attr(feature = "cfg-target-has-atomic", feature(cfg_target_has_atomic))] 15 16 #![cfg_attr(not(feature = "std"), no_std)] 17 18 #![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)] 19 // It cannot be included in the published code because this lints have false positives in the minimum required version. 20 #![cfg_attr(test, warn(single_use_lifetimes))] 21 #![warn(clippy::all)] 22 #![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))] 23 24 #[cfg(all(feature = "cfg-target-has-atomic", not(feature = "unstable")))] 25 compile_error!("The `cfg-target-has-atomic` feature requires the `unstable` feature as an explicit opt-in to unstable features"); 26 27 macro_rules! cfg_target_has_atomic { 28 ($($item:item)*) => {$( 29 #[cfg_attr(feature = "cfg-target-has-atomic", cfg(target_has_atomic = "ptr"))] 30 $item 31 )*}; 32 } 33 34 cfg_target_has_atomic! { 35 #[cfg(feature = "alloc")] 36 extern crate alloc; 37 38 #[cfg(feature = "alloc")] 39 mod lock; 40 #[cfg(feature = "std")] 41 pub mod mpsc; 42 #[cfg(feature = "alloc")] 43 pub mod oneshot; 44 } 45