Skip to content

Commit

Permalink
fix loom test about Arc and features
Browse files Browse the repository at this point in the history
  • Loading branch information
biluohc committed Dec 7, 2019
1 parent 261c9df commit 9eac870
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tokio/src/runtime/builder.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -65,7 +67,7 @@ pub struct Builder {
pub(super) before_stop: Option<Callback>,
}

pub(crate) type ThreadNameFn = Arc<dyn Fn() -> String + Send + Sync + 'static>;
pub(crate) type ThreadNameFn = Arc<Box<dyn Fn() -> String + Send + Sync + 'static>>;

#[derive(Debug, Clone, Copy)]
enum Kind {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -171,7 +173,7 @@ impl Builder {
/// ```
pub fn thread_name(&mut self, val: impl Into<String>) -> &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
}

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 9eac870

Please sign in to comment.