From 361c812e6aba4a414304457fb9170014159e4978 Mon Sep 17 00:00:00 2001 From: Fenrir Date: Wed, 26 Jul 2017 01:53:40 -0600 Subject: Thread fixes + module update --- ctr-std/src/sys_common/thread_info.rs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'ctr-std/src/sys_common') diff --git a/ctr-std/src/sys_common/thread_info.rs b/ctr-std/src/sys_common/thread_info.rs index 95d8b6c..2abb8af 100644 --- a/ctr-std/src/sys_common/thread_info.rs +++ b/ctr-std/src/sys_common/thread_info.rs @@ -12,7 +12,6 @@ use cell::RefCell; use thread::Thread; -use thread::LocalKeyState; struct ThreadInfo { stack_guard: Option, @@ -23,19 +22,15 @@ thread_local! { static THREAD_INFO: RefCell> = RefCell::new(N impl ThreadInfo { fn with(f: F) -> Option where F: FnOnce(&mut ThreadInfo) -> R { - if THREAD_INFO.state() == LocalKeyState::Destroyed { - return None - } - - THREAD_INFO.with(move |c| { + THREAD_INFO.try_with(move |c| { if c.borrow().is_none() { *c.borrow_mut() = Some(ThreadInfo { stack_guard: None, - thread: NewThread::new(None), + thread: Thread::new(None), }) } - Some(f(c.borrow_mut().as_mut().unwrap())) - }) + f(c.borrow_mut().as_mut().unwrap()) + }).ok() } } @@ -54,8 +49,3 @@ pub fn set(stack_guard: Option, thread: Thread) { thread: thread, })); } - -// a hack to get around privacy restrictions; implemented by `std::thread` -pub trait NewThread { - fn new(name: Option) -> Self; -} -- cgit v1.2.3