From dca49e06b18c63185a60e73f4ccde77ed541c079 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 4 Feb 2015 02:26:00 +0100 Subject: [PATCH 1/2] Move native thread name setting from thread_info to Thread, fixes #21911 --- src/libstd/sys/common/thread_info.rs | 4 ---- src/libstd/thread.rs | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libstd/sys/common/thread_info.rs b/src/libstd/sys/common/thread_info.rs index ce67a584a0a..92b936e74f6 100644 --- a/src/libstd/sys/common/thread_info.rs +++ b/src/libstd/sys/common/thread_info.rs @@ -56,10 +56,6 @@ pub fn stack_guard() -> uint { pub fn set(stack_bounds: (uint, uint), stack_guard: uint, thread: Thread) { THREAD_INFO.with(|c| assert!(c.borrow().is_none())); - match thread.name() { - Some(name) => unsafe { ::sys::thread::set_name(name); }, - None => {} - } THREAD_INFO.with(move |c| *c.borrow_mut() = Some(ThreadInfo{ stack_bounds: stack_bounds, stack_guard: stack_guard, diff --git a/src/libstd/thread.rs b/src/libstd/thread.rs index eb967c9f4e3..dda97bec925 100644 --- a/src/libstd/thread.rs +++ b/src/libstd/thread.rs @@ -280,6 +280,10 @@ fn spawn_inner(self, f: Thunk<(), T>, finish: Thunk, ()>) unsafe { stack::record_os_managed_stack_bounds(my_stack_bottom, my_stack_top); } + match their_thread.name() { + Some(name) => unsafe { imp::set_name(name.as_slice()); }, + None => {} + } thread_info::set( (my_stack_bottom, my_stack_top), unsafe { imp::guard::current() }, From 7d2404cb420591588684d4681cf81fe8cff1ace3 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Tue, 10 Feb 2015 15:06:45 +0100 Subject: [PATCH 2/2] Move native thread name setting from thread_info to Thread, fixes #21911 --- src/libstd/thread.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libstd/thread.rs b/src/libstd/thread.rs index dda97bec925..cc9d7492441 100644 --- a/src/libstd/thread.rs +++ b/src/libstd/thread.rs @@ -156,6 +156,7 @@ use option::Option::{self, Some, None}; use result::Result::{Err, Ok}; use sync::{Mutex, Condvar, Arc}; +use str::Str; use string::String; use rt::{self, unwind}; use old_io::{Writer, stdio};