chore: name the spawned thread

This commit is contained in:
Shunsuke Shibayama 2023-03-22 22:00:38 +09:00
parent 0079aed860
commit 8bb91cfe11
6 changed files with 8 additions and 7 deletions

View file

@ -15,7 +15,7 @@ macro_rules! enable_overflow_stacktrace {
/// Execute a function in a new thread on Windows, otherwise just run it.
///
/// Windows has a smaller default stack size than other OSs, which may cause a stack overflow, especially in the parsing process.
pub fn exec_new_thread<F, T>(run: F) -> T
pub fn exec_new_thread<F, T>(run: F, name: &str) -> T
where
F: FnOnce() -> T + Send + 'static,
T: Send + 'static,
@ -24,6 +24,7 @@ where
if cfg!(windows) || cfg!(feature = "large_thread") {
const STACK_SIZE: usize = 4 * 1024 * 1024;
let child = thread::Builder::new()
.name(name.to_string())
.stack_size(STACK_SIZE)
.spawn(run)
.unwrap();