diff options
| author | Fenrir <[email protected]> | 2017-07-26 01:53:40 -0600 |
|---|---|---|
| committer | Fenrir <[email protected]> | 2017-07-26 01:53:40 -0600 |
| commit | 361c812e6aba4a414304457fb9170014159e4978 (patch) | |
| tree | 6ac98462bd1eb469b2b09623719142bc87d62861 /ctr-std/src/sys_common | |
| parent | Merge pull request #36 from FenrirWolf/errDisp (diff) | |
| download | ctru-rs-361c812e6aba4a414304457fb9170014159e4978.tar.xz ctru-rs-361c812e6aba4a414304457fb9170014159e4978.zip | |
Thread fixes + module update
Diffstat (limited to 'ctr-std/src/sys_common')
| -rw-r--r-- | ctr-std/src/sys_common/thread_info.rs | 18 |
1 files changed, 4 insertions, 14 deletions
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<usize>, @@ -23,19 +22,15 @@ thread_local! { static THREAD_INFO: RefCell<Option<ThreadInfo>> = RefCell::new(N impl ThreadInfo { fn with<R, F>(f: F) -> Option<R> 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<usize>, thread: Thread) { thread: thread, })); } - -// a hack to get around privacy restrictions; implemented by `std::thread` -pub trait NewThread { - fn new(name: Option<String>) -> Self; -} |