@@ -694,9 +694,7 @@ pub(crate) fn set_current(thread: Thread) {
|
||||
/// In contrast to the public `current` function, this will not panic if called
|
||||
/// from inside a TLS destructor.
|
||||
pub(crate) fn try_current() -> Option<Thread> {
|
||||
CURRENT
|
||||
.try_with(|current| current.get_or_init(|| Thread::new(imp::Thread::get_name())).clone())
|
||||
.ok()
|
||||
CURRENT.try_with(|current| current.get_or_init(|| Thread::new(None)).clone()).ok()
|
||||
}
|
||||
|
||||
/// Gets a handle to the thread that invokes it.
|
||||
|
||||
@@ -69,26 +69,6 @@ fn test_named_thread_truncation() {
|
||||
result.unwrap().join().unwrap();
|
||||
}
|
||||
|
||||
#[cfg(any(
|
||||
all(target_os = "windows", not(target_vendor = "win7")),
|
||||
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;
|
||||
// Spawn a new thread to avoid interfering with other tests running on this 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();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn test_invalid_named_thread() {
|
||||
|
||||
Reference in New Issue
Block a user