diff --git a/tokio/src/runtime/builder.rs b/tokio/src/runtime/builder.rs index 77c2e200d25..be696317498 100644 --- a/tokio/src/runtime/builder.rs +++ b/tokio/src/runtime/builder.rs @@ -2,10 +2,7 @@ use crate::runtime::handle::Handle; use crate::runtime::shell::Shell; use crate::runtime::{blocking, io, time, Callback, Runtime, Spawner}; -#[cfg(loom)] -use crate::loom::sync::Arc; use std::fmt; -#[cfg(not(loom))] use std::sync::Arc; /// Builds Tokio Runtime with custom configuration values. @@ -70,7 +67,7 @@ pub struct Builder { pub(super) before_stop: Option, } -pub(crate) type ThreadNameFn = Arc String + Send + Sync + 'static>>; +pub(crate) type ThreadNameFn = Arc String + Send + Sync + 'static>; #[derive(Debug, Clone, Copy)] enum Kind { @@ -103,7 +100,7 @@ impl Builder { max_threads: 512, // Default thread name - thread_name: Arc::new(Box::new(|| "tokio-runtime-worker".into())), + thread_name: Arc::new(|| "tokio-runtime-worker".into()), // Do not set a stack size by default thread_stack_size: None, @@ -215,7 +212,7 @@ impl Builder { /// ``` pub fn thread_name(&mut self, val: impl Into) -> &mut Self { let val = val.into(); - self.thread_name = Arc::new(Box::new(move || val.clone())); + self.thread_name = Arc::new(move || val.clone()); self } @@ -243,7 +240,7 @@ impl Builder { where F: Fn() -> String + Send + Sync + 'static, { - self.thread_name = Arc::new(Box::new(f)); + self.thread_name = Arc::new(f); self } @@ -543,7 +540,10 @@ impl fmt::Debug for Builder { .field("kind", &self.kind) .field("core_threads", &self.core_threads) .field("max_threads", &self.max_threads) - .field("thread_name", &" String + Send + Sync + 'static>") + .field( + "thread_name", + &" String + Send + Sync + 'static>", + ) .field("thread_stack_size", &self.thread_stack_size) .field("after_start", &self.after_start.as_ref().map(|_| "...")) .field("before_stop", &self.after_start.as_ref().map(|_| "..."))