Skip to content

Commit

Permalink
Set ThreadPool::pool_size to 1 if num_cpus::get() returns 0
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e authored and cramertj committed Aug 29, 2019
1 parent e9cd539 commit 4c96148
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions futures-executor/src/thread_pool.rs
Original file line number Diff line number Diff line change
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

0 comments on commit 4c96148

Please sign in to comment.