Skip to content

Commit

Permalink
core: registry: Rename ThreadPoolBuilder::use_current to use_current_…
Browse files Browse the repository at this point in the history
…thread.

As per suggestion in rayon-rs#1052.
  • Loading branch information
emilio committed Sep 20, 2023
1 parent 9461f7b commit 18f6861
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions rayon-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ pub struct ThreadPoolBuilder<S = DefaultSpawn> {
num_threads: usize,

/// The thread we're building *from* will also be part of the pool.
use_current: bool,
use_current_thread: bool,

/// Custom closure, if any, to handle a panic that we cannot propagate
/// anywhere else.
Expand Down Expand Up @@ -230,7 +230,7 @@ impl Default for ThreadPoolBuilder {
fn default() -> Self {
ThreadPoolBuilder {
num_threads: 0,
use_current: false,
use_current_thread: false,
panic_handler: None,
get_thread_name: None,
stack_size: None,
Expand Down Expand Up @@ -441,7 +441,7 @@ impl<S> ThreadPoolBuilder<S> {
spawn_handler: CustomSpawn::new(spawn),
// ..self
num_threads: self.num_threads,
use_current: self.use_current,
use_current_thread: self.use_current_thread,
panic_handler: self.panic_handler,
get_thread_name: self.get_thread_name,
stack_size: self.stack_size,
Expand Down Expand Up @@ -535,8 +535,8 @@ impl<S> ThreadPoolBuilder<S> {
}

/// Use the current thread as one of the threads in the pool.
pub fn use_current(mut self) -> Self {
self.use_current = true;
pub fn use_current_thread(mut self) -> Self {
self.use_current_thread = true;
self
}

Expand Down Expand Up @@ -779,7 +779,7 @@ impl<S> fmt::Debug for ThreadPoolBuilder<S> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let ThreadPoolBuilder {
ref num_threads,
ref use_current,
ref use_current_thread,
ref get_thread_name,
ref panic_handler,
ref stack_size,
Expand All @@ -804,7 +804,7 @@ impl<S> fmt::Debug for ThreadPoolBuilder<S> {

f.debug_struct("ThreadPoolBuilder")
.field("num_threads", num_threads)
.field("use_current", use_current)
.field("use_current_thread", use_current_thread)
.field("get_thread_name", &get_thread_name)
.field("panic_handler", &panic_handler)
.field("stack_size", &stack_size)
Expand Down
4 changes: 2 additions & 2 deletions rayon-core/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ fn default_global_registry() -> Result<Arc<Registry>, ThreadPoolBuildError> {
// is stubbed out, and we won't have to change anything if they do add real threading.
let unsupported = matches!(&result, Err(e) if e.is_unsupported());
if unsupported && WorkerThread::current().is_null() {
let builder = ThreadPoolBuilder::new().num_threads(1).use_current();
let builder = ThreadPoolBuilder::new().num_threads(1).use_current_thread();
let fallback_result = Registry::new(builder);
if fallback_result.is_ok() {
return fallback_result;
Expand Down Expand Up @@ -282,7 +282,7 @@ impl Registry {
index,
};

if index == 0 && builder.use_current {
if index == 0 && builder.use_current_thread {
// Rather than starting a new thread, we're just taking over the current thread
// *without* running the main loop, so we can still return from here.
// The WorkerThread is leaked, but we never shutdown the global pool anyway.
Expand Down

0 comments on commit 18f6861

Please sign in to comment.