-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Use the OS thread name by default if THREAD_INFO
has not been initialized
#121666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,25 @@ fn test_named_thread_truncation() { | |
result.unwrap().join().unwrap(); | ||
} | ||
|
||
#[cfg(any( | ||
target_os = "windows", | ||
target_os = "linux", | ||
target_os = "macos", | ||
target_os = "ios", | ||
target_os = "tvos", | ||
target_os = "watchos" | ||
))] | ||
#[test] | ||
fn test_get_os_named_thread() { | ||
use crate::sys::thread::Thread; | ||
let handler = thread::spawn(|| { | ||
let name = c"test me please"; | ||
Thread::set_name(name); | ||
assert_eq!(name, Thread::get_name().unwrap().as_c_str()); | ||
}); | ||
handler.join().unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a particular reason why this test runs in a new thread, rather than the main thread? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was worried about affecting the thread name for all tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, makes sense. A comment explaining that would have avoided some surprise and confusion here. :) |
||
} | ||
|
||
#[test] | ||
#[should_panic] | ||
fn test_invalid_named_thread() { | ||
|
Uh oh!
There was an error while loading. Please reload this page.