Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

futures: enable testing without --features thread-pool #2098

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions futures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<i32>();
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion futures/tests/eventual.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(feature = "thread-pool")]
use futures::channel::oneshot;
use futures::executor::ThreadPool;
use futures::future::{self, ok, Future, FutureExt, TryFutureExt};
Expand All @@ -9,7 +10,6 @@ fn run<F: Future + Send + 'static>(future: F) {
let tp = ThreadPool::new().unwrap();
tp.spawn(future.map(drop)).unwrap();
}

#[test]
fn join1() {
let (tx, rx) = mpsc::channel();
Expand Down
14 changes: 12 additions & 2 deletions futures/tests/mutex.rs
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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();
Expand Down