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

Set ThreadPool::pool_size to 1 if num_cpus::get() returns 0 #1835

Merged
merged 1 commit into from Aug 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions futures-executor/src/thread_pool.rs
Expand Up @@ -4,12 +4,13 @@ use futures_core::future::{Future, FutureObj};
use futures_core::task::{Context, Poll, Spawn, SpawnError};
use futures_util::future::FutureExt;
use futures_util::task::{ArcWake, waker_ref};
use std::cmp;
use std::fmt;
use std::io;
use std::sync::{Arc, Mutex};
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::mpsc;
use std::sync::{Arc, Mutex};
use std::thread;
use std::fmt;

/// A general-purpose thread pool for scheduling tasks that poll futures to
/// completion.
Expand Down Expand Up @@ -203,7 +204,7 @@ impl ThreadPoolBuilder {
/// See the other methods on this type for details on the defaults.
pub fn new() -> ThreadPoolBuilder {
ThreadPoolBuilder {
pool_size: num_cpus::get(),
pool_size: cmp::max(1, num_cpus::get()),
stack_size: 0,
name_prefix: None,
after_start: None,
Expand Down