We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 97ea37e commit 07359efCopy full SHA for 07359ef
futures-executor/Cargo.toml
@@ -13,13 +13,12 @@ Executors for asynchronous tasks based on the futures-rs library.
13
[features]
14
default = ["std"]
15
std = ["futures-core/std", "futures-task/std", "futures-util/std"]
16
-thread-pool = ["std", "num_cpus"]
+thread-pool = ["std"]
17
18
[dependencies]
19
futures-core = { path = "../futures-core", version = "=1.0.0-alpha.0", default-features = false }
20
futures-task = { path = "../futures-task", version = "=0.4.0-alpha.0", default-features = false }
21
futures-util = { path = "../futures-util", version = "=0.4.0-alpha.0", default-features = false }
22
-num_cpus = { version = "1.8.0", optional = true }
23
24
[dev-dependencies]
25
futures = { path = "../futures", features = ["thread-pool"] }
futures-executor/src/thread_pool.rs
@@ -6,7 +6,6 @@ use futures_task::{waker_ref, ArcWake};
6
use futures_task::{FutureObj, Spawn, SpawnError};
7
use futures_util::future::FutureExt;
8
use std::boxed::Box;
9
-use std::cmp;
10
use std::fmt;
11
use std::format;
12
use std::io;
@@ -190,13 +189,8 @@ impl ThreadPoolBuilder {
190
189
///
191
/// See the other methods on this type for details on the defaults.
192
pub fn new() -> Self {
193
- Self {
194
- pool_size: cmp::max(1, num_cpus::get()),
195
- stack_size: 0,
196
- name_prefix: None,
197
- after_start: None,
198
- before_stop: None,
199
- }
+ let pool_size = thread::available_parallelism().map_or(1, |p| p.get());
+ Self { pool_size, stack_size: 0, name_prefix: None, after_start: None, before_stop: None }
200
}
201
202
/// Set size of a future ThreadPool
@@ -283,7 +277,7 @@ impl ThreadPoolBuilder {
283
277
let before_stop = self.before_stop.clone();
284
278
let mut thread_builder = thread::Builder::new();
285
279
if let Some(ref name_prefix) = self.name_prefix {
286
- thread_builder = thread_builder.name(format!("{}{}", name_prefix, counter));
280
+ thread_builder = thread_builder.name(format!("{name_prefix}{counter}"));
287
281
288
282
if self.stack_size > 0 {
289
thread_builder = thread_builder.stack_size(self.stack_size);
futures-util/Cargo.toml
@@ -16,8 +16,8 @@ std = ["alloc", "futures-core/std", "futures-task/std", "slab/std"]
alloc = ["futures-core/alloc", "futures-task/alloc", "slab"]
async-await = []
async-await-macro = ["async-await", "futures-macro"]
-compat = ["std", "futures_01"]
-io-compat = ["io", "compat", "tokio-io"]
+compat = ["std", "futures_01", "libc"]
+io-compat = ["io", "compat", "tokio-io", "libc"]
sink = ["futures-sink"]
io = ["std", "futures-io", "memchr"]
channel = ["std", "futures-channel"]
@@ -44,6 +44,9 @@ tokio-io = { version = "0.1.9", optional = true }
44
pin-project-lite = "0.2.6"
45
spin = { version = "0.10.0", optional = true }
46
47
+# INDIRECT DEPENDENCYS BUT ONLY FOR SPECIFIC MINIMAL VERSIONS
48
+libc = { version = "0.2.26", optional = true }
49
+
50
51
futures = { path = "../futures", features = ["async-await", "thread-pool"] }
52
futures-test = { path = "../futures-test" }
futures-util/src/lock/mutex.rs
@@ -553,8 +553,8 @@ mod tests {
553
fn test_mutex_guard_debug_not_recurse() {
554
let mutex = Mutex::new(42);
555
let guard = mutex.try_lock().unwrap();
556
- let _ = format!("{:?}", guard);
+ let _ = format!("{guard:?}");
557
let guard = MutexGuard::map(guard, |n| n);
558
559
560
futures-util/src/stream/futures_unordered/ready_to_run_queue.rs
@@ -69,7 +69,7 @@ impl<Fut> ReadyToRunQueue<Fut> {
69
return Dequeue::Data(tail);
70
71
72
- if self.head.load(Acquire) as *const _ != tail {
+ if !core::ptr::eq(self.head.load(Acquire), tail) {
73
return Dequeue::Inconsistent;
74
75
futures-util/src/stream/stream/try_for_each_concurrent.rs
@@ -1,6 +1,5 @@
1
use crate::stream::{FuturesUnordered, StreamExt};
2
use core::fmt;
3
-use core::mem;
4
use core::num::NonZeroUsize;
5
use core::pin::Pin;
use futures_core::future::{FusedFuture, Future};
@@ -113,7 +112,7 @@ where
113
112
// Empty the stream and futures so that we know
114
// the future has completed.
115
this.stream.set(None);
116
- drop(mem::replace(this.futures, FuturesUnordered::new()));
+ drop(core::mem::take(this.futures));
117
return Poll::Ready(Err(e));
118
119
futures/tests/oneshot.rs
@@ -68,11 +68,11 @@ fn oneshot_drop_rx() {
68
#[test]
fn oneshot_debug() {
let (tx, rx) = oneshot::channel::<i32>();
- assert_eq!(format!("{:?}", tx), "Sender { complete: false }");
- assert_eq!(format!("{:?}", rx), "Receiver { complete: false }");
+ assert_eq!(format!("{tx:?}"), "Sender { complete: false }");
+ assert_eq!(format!("{rx:?}"), "Receiver { complete: false }");
drop(rx);
- assert_eq!(format!("{:?}", tx), "Sender { complete: true }");
+ assert_eq!(format!("{tx:?}"), "Sender { complete: true }");
76
drop(tx);
77
- assert_eq!(format!("{:?}", rx), "Receiver { complete: true }");
+ assert_eq!(format!("{rx:?}"), "Receiver { complete: true }");
78
0 commit comments