From be11aa6d70c90185db715328ef2b24a3621cb969 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 30 Dec 2014 15:20:47 -0800 Subject: std: Second pass stabilization for thread_local This commit performs a second pass over the `std::thread_local` module. Most of the functionality remains explicitly unstable, but the specific actions taken were: * `thread_local` is now stable * `thread_local!` is now stable * `thread_local::Key` is now stable * `thread_local::Key::with` is now stable * `thread_local::Key::destroyed` is deprecated in favor of a more general `state` function * `thread_local::Key::state` was added to query the three states that a key can be in: uninitialized, valid, or destroyed. This function, and the corresponding `State` enum, are both marked unstable as we may wish to expand it later on. * `thread_local::scoped` is entirely unstable. There hasn't been a whole lot of usage of this module in the standard distribution, so it remains unstable at this time. Note that while the structure `Key` is marked stable, it is currently forced to expose all of its implementation details due to the use of construction-via-macro. The use of construction-via-macro is currently required in order to place the `#[thread_local]` attribute on static in a platform-specific manner. These stability attributes were assigned assuming that it will be acceptable to tweak the implementation of `Key` in the future. --- src/libstd/sys/common/thread_info.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/libstd/sys') diff --git a/src/libstd/sys/common/thread_info.rs b/src/libstd/sys/common/thread_info.rs index dc21feb17a8..b8bff23d583 100644 --- a/src/libstd/sys/common/thread_info.rs +++ b/src/libstd/sys/common/thread_info.rs @@ -10,9 +10,10 @@ use core::prelude::*; -use thread::Thread; use cell::RefCell; use string::String; +use thread::Thread; +use thread_local::State; struct ThreadInfo { // This field holds the known bounds of the stack in (lo, hi) @@ -27,7 +28,7 @@ thread_local! { static THREAD_INFO: RefCell> = RefCell::new(N impl ThreadInfo { fn with(f: |&mut ThreadInfo| -> R) -> R { - if THREAD_INFO.destroyed() { + if THREAD_INFO.state() == State::Destroyed { panic!("Use of std::thread::Thread::current() is not possible after \ the thread's local data has been destroyed"); } -- cgit 1.4.1-3-g733a5