diff --git a/tokio/src/runtime/builder.rs b/tokio/src/runtime/builder.rs index ae9f6d68e33..2622a61da24 100644 --- a/tokio/src/runtime/builder.rs +++ b/tokio/src/runtime/builder.rs @@ -2,6 +2,8 @@ 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; @@ -65,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 { @@ -96,7 +98,7 @@ impl Builder { num_threads: crate::loom::sys::num_cpus(), // Default thread name - thread_name: Arc::new(|| "tokio-runtime-worker".into()), + thread_name: Arc::new(Box::new(|| "tokio-runtime-worker".into())), // Do not set a stack size by default thread_stack_size: None, @@ -171,7 +173,7 @@ impl Builder { /// ``` pub fn thread_name(&mut self, val: impl Into) -> &mut Self { let val = val.into(); - self.thread_name = Arc::new(move || val.clone()); + self.thread_name = Arc::new(Box::new(move || val.clone())); self } @@ -199,7 +201,7 @@ impl Builder { where F: Fn() -> String + Send + Sync + 'static, { - self.thread_name = Arc::new(f); + self.thread_name = Arc::new(Box::new(f)); self }