diff --git a/futures/src/lib.rs b/futures/src/lib.rs index c4acbc0fd1..26807af701 100644 --- a/futures/src/lib.rs +++ b/futures/src/lib.rs @@ -25,11 +25,16 @@ //! within macros and keywords such as async and await!. //! //! ```rust +//! # #[cfg(features = "thread-pool")] //! # use futures::channel::mpsc; +//! # #[cfg(features = "thread-pool")] //! # use futures::executor; ///standard executors to provide a context for futures and streams +//! # #[cfg(features = "thread-pool")] //! # use futures::executor::ThreadPool; +//! # #[cfg(features = "thread-pool")] //! # use futures::StreamExt; //! +//! # #[cfg(features = "thread-pool")] //! fn main() { //! let pool = ThreadPool::new().expect("Failed to build pool"); //! let (tx, rx) = mpsc::unbounded::(); @@ -73,6 +78,9 @@ //! //! println!("Values={:?}", values); //! } +//! +//! # #[cfg(not(features = "thread-pool"))] +//! # fn main() { } //! ``` //! //! The majority of examples and code snippets in this crate assume that they are diff --git a/futures/tests/eventual.rs b/futures/tests/eventual.rs index bff000dd09..883ed219d4 100644 --- a/futures/tests/eventual.rs +++ b/futures/tests/eventual.rs @@ -1,3 +1,4 @@ +#![cfg(feature = "thread-pool")] use futures::channel::oneshot; use futures::executor::ThreadPool; use futures::future::{self, ok, Future, FutureExt, TryFutureExt}; @@ -9,7 +10,6 @@ fn run(future: F) { let tp = ThreadPool::new().unwrap(); tp.spawn(future.map(drop)).unwrap(); } - #[test] fn join1() { let (tx, rx) = mpsc::channel(); diff --git a/futures/tests/mutex.rs b/futures/tests/mutex.rs index bad53a9b8f..76025215a0 100644 --- a/futures/tests/mutex.rs +++ b/futures/tests/mutex.rs @@ -1,11 +1,20 @@ +#[cfg(feature = "thread-pool")] use futures::channel::mpsc; +#[cfg(feature = "thread-pool")] use futures::executor::block_on; -use futures::future::{ready, FutureExt}; +#[cfg(feature = "thread-pool")] +use futures::future::ready; +use futures::future::FutureExt; use futures::lock::Mutex; +#[cfg(feature = "thread-pool")] use futures::stream::StreamExt; -use futures::task::{Context, SpawnExt}; +use futures::task::Context; +#[cfg(feature = "thread-pool")] +use futures::task::SpawnExt; +#[cfg(feature = "thread-pool")] use futures_test::future::FutureTestExt; use futures_test::task::{new_count_waker, panic_context}; +#[cfg(feature = "thread-pool")] use std::sync::Arc; #[test] @@ -34,6 +43,7 @@ fn mutex_wakes_waiters() { assert!(waiter.poll_unpin(&mut panic_context()).is_ready()); } +#[cfg(feature = "thread-pool")] #[test] fn mutex_contested() { let (tx, mut rx) = mpsc::unbounded();