runtime: add thread_name_fn method to runtime::Builder (#1921)

Fixes: #1907
This commit is contained in:
wspsxing
2020-08-24 15:14:20 +02:00
committed by GitHub
parent 9d58b70151
commit 4e12299826
2 changed files with 42 additions and 8 deletions
+3 -2
View File
@@ -5,6 +5,7 @@ use crate::loom::thread;
use crate::runtime::blocking::schedule::NoopSchedule;
use crate::runtime::blocking::shutdown;
use crate::runtime::blocking::task::BlockingTask;
use crate::runtime::builder::ThreadNameFn;
use crate::runtime::task::{self, JoinHandle};
use crate::runtime::{Builder, Callback, Handle};
@@ -32,7 +33,7 @@ struct Inner {
condvar: Condvar,
/// Spawned threads use this name
thread_name: String,
thread_name: ThreadNameFn,
/// Spawned thread stack size
stack_size: Option<usize>,
@@ -214,7 +215,7 @@ impl Spawner {
rt: &Handle,
worker_id: usize,
) -> thread::JoinHandle<()> {
let mut builder = thread::Builder::new().name(self.inner.thread_name.clone());
let mut builder = thread::Builder::new().name((self.inner.thread_name)());
if let Some(stack_size) = self.inner.stack_size {
builder = builder.stack_size(stack_size);