Skip to content

Commit a3e5962

Browse files
taiki-ecramertj
authored andcommitted
Make ThreadPool optional
1 parent 6c552a7 commit a3e5962

File tree

6 files changed

+32
-6
lines changed

6 files changed

+32
-6
lines changed

.travis.yml

+17-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ matrix:
1515
- name: cargo build (minimum required version)
1616
rust: 1.36.0
1717
script:
18-
# default features & compat feature
1918
- cargo run --manifest-path ci/remove-dev-dependencies/Cargo.toml */Cargo.toml
19+
# Check default-features
2020
- cargo build --all
21+
# Check compat & threadpool features
2122
- cargo build --manifest-path futures/Cargo.toml --features io-compat
23+
- cargo build --manifest-path futures/Cargo.toml --features threadpool
2224

2325
# This is the minimum Rust version supported by `async-await` feature.
2426
# When updating this, the reminder to update the minimum required version of `async-await` feature in README.md.
@@ -31,18 +33,22 @@ matrix:
3133
- name: cargo +stable build
3234
rust: stable
3335
script:
34-
# default features & compat feature
3536
- cargo run --manifest-path ci/remove-dev-dependencies/Cargo.toml */Cargo.toml
37+
# Check default-features
3638
- cargo build --all
39+
# Check compat & threadpool features
3740
- cargo build --manifest-path futures/Cargo.toml --features io-compat
41+
- cargo build --manifest-path futures/Cargo.toml --features threadpool
3842

3943
- name: cargo +beta build
4044
rust: beta
4145
script:
42-
# default features & compat feature & async-await feature
4346
- cargo run --manifest-path ci/remove-dev-dependencies/Cargo.toml */Cargo.toml
47+
# Check default-features
4448
- cargo build --all
49+
# Check compat & threadpool & async-await features
4550
- cargo build --manifest-path futures/Cargo.toml --features io-compat
51+
- cargo build --manifest-path futures/Cargo.toml --features threadpool
4652
- cargo build --manifest-path futures/Cargo.toml --features async-await
4753

4854
- name: cargo test
@@ -169,7 +175,7 @@ matrix:
169175
- cargo check --manifest-path futures-util/Cargo.toml --features io,bilock,unstable
170176
- cargo check --manifest-path futures-util/Cargo.toml --features sink,io
171177
- cargo check --manifest-path futures-util/Cargo.toml --features read_initializer,unstable
172-
178+
# Check each features with --no-default-features
173179
- cargo check --manifest-path futures-util/Cargo.toml --no-default-features
174180
- cargo check --manifest-path futures-util/Cargo.toml --no-default-features --features sink
175181
- cargo check --manifest-path futures-util/Cargo.toml --no-default-features --features alloc,sink
@@ -178,6 +184,13 @@ matrix:
178184
- cargo check --manifest-path futures-util/Cargo.toml --no-default-features --features sink,bilock,unstable
179185
- cargo check --manifest-path futures-util/Cargo.toml --no-default-features --features io,bilock,unstable
180186

187+
# futures-executor
188+
# Check default-features, all-features
189+
- cargo check --manifest-path futures-executor/Cargo.toml
190+
- cargo check --manifest-path futures-executor/Cargo.toml --all-features
191+
# Check each features
192+
- cargo check --manifest-path futures-executor/Cargo.toml --features threadpool
193+
181194
- name: cargo doc
182195
rust: nightly
183196
script:

futures-executor/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ name = "futures_executor"
1616

1717
[features]
1818
default = ["std"]
19-
std = ["futures-core-preview/std", "futures-util-preview/std", "num_cpus"]
19+
std = ["futures-core-preview/std", "futures-util-preview/std"]
20+
threadpool = ["num_cpus"]
2021

2122
[dependencies]
2223
futures-core-preview = { path = "../futures-core", version = "=0.3.0-alpha.19", default-features = false }

futures-executor/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ mod local_pool;
1919
#[cfg(feature = "std")]
2020
pub use crate::local_pool::{block_on, block_on_stream, BlockingStream, LocalPool, LocalSpawner};
2121

22+
#[cfg(feature = "threadpool")]
2223
#[cfg(feature = "std")]
2324
mod unpark_mutex;
25+
#[cfg(feature = "threadpool")]
2426
#[cfg(feature = "std")]
2527
mod thread_pool;
28+
#[cfg(feature = "threadpool")]
2629
#[cfg(feature = "std")]
2730
pub use crate::thread_pool::{ThreadPool, ThreadPoolBuilder};
2831

futures-executor/src/thread_pool.rs

+6
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,17 @@ use std::thread;
2020
///
2121
/// This type is a clonable handle to the threadpool itself.
2222
/// Cloning it will only create a new reference, not a new threadpool.
23+
///
24+
/// This type is only available when the `threadpool` feature of this
25+
/// library is activated.
2326
pub struct ThreadPool {
2427
state: Arc<PoolState>,
2528
}
2629

2730
/// Thread pool configuration object.
31+
///
32+
/// This type is only available when the `threadpool` feature of this
33+
/// library is activated.
2834
pub struct ThreadPoolBuilder {
2935
pool_size: usize,
3036
stack_size: usize,

futures/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ alloc = ["futures-core-preview/alloc", "futures-sink-preview/alloc", "futures-ch
4242
async-await = ["futures-util-preview/async-await", "futures-util-preview/join-macro", "futures-util-preview/select-macro"]
4343
compat = ["std", "futures-util-preview/compat"]
4444
io-compat = ["compat", "futures-util-preview/io-compat"]
45+
threadpool = ["futures-executor-preview/threadpool"]
4546

4647
# Unstable features
4748
# These features are outside of the normal semver guarantees and require the

futures/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,11 @@ pub mod executor {
191191
BlockingStream,
192192
Enter, EnterError,
193193
LocalSpawner, LocalPool,
194-
ThreadPool, ThreadPoolBuilder,
195194
block_on, block_on_stream, enter,
196195
};
196+
197+
#[cfg(feature = "threadpool")]
198+
pub use futures_executor::{ThreadPool, ThreadPoolBuilder};
197199
}
198200

199201
pub mod future {

0 commit comments

Comments
 (0)