Rollup merge of #121666 - ChrisDenton:thread-name, r=cuviper
Use the OS thread name by default if `THREAD_INFO` has not been initialized Currently if `THREAD_INFO` hasn't been initialized then the name will be set to `None`. This PR changes it to use the OS thread name by default. This mostly affects foreign threads at the moment but we could expand this to make more use of the OS thread name in the future. Note: I've only implemented `Thread::get_name` for windows, linux and macos (and macos adjacent) targets. The rest just return `None`.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#![allow(dead_code)] // stack_guard isn't used right now on all platforms
|
||||
|
||||
use crate::cell::OnceCell;
|
||||
use crate::sys;
|
||||
use crate::sys::thread::guard::Guard;
|
||||
use crate::thread::Thread;
|
||||
|
||||
@@ -23,7 +24,8 @@ impl ThreadInfo {
|
||||
{
|
||||
THREAD_INFO
|
||||
.try_with(move |thread_info| {
|
||||
let thread = thread_info.thread.get_or_init(|| Thread::new(None));
|
||||
let thread =
|
||||
thread_info.thread.get_or_init(|| Thread::new(sys::thread::Thread::get_name()));
|
||||
f(thread, &thread_info.stack_guard)
|
||||
})
|
||||
.ok()
|
||||
|
||||
Reference in New Issue
Block a user