mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Make current_thread_unique_ptr work during thread destruction.
Otherwise we can't use println!() within atexit handlers etc.
This commit is contained in:
parent
bd61bec67d
commit
ebebe6f837
@ -34,7 +34,9 @@ impl ThreadInfo {
|
||||
///
|
||||
/// This can be used as a non-null usize-sized ID.
|
||||
pub fn current_thread_unique_ptr() -> usize {
|
||||
THREAD_INFO.with(|info| <*const _>::addr(info))
|
||||
// Use a non-drop type to make sure it's still available during thread destruction.
|
||||
thread_local! { static X: u8 = 0 }
|
||||
X.with(|x| <*const _>::addr(x))
|
||||
}
|
||||
|
||||
pub fn current_thread() -> Option<Thread> {
|
||||
|
Loading…
Reference in New Issue
Block a user