Move current_thread_unique_ptr to the only module that uses it.

This commit is contained in:
Mara Bos 2022-04-06 22:12:47 +02:00
parent ebebe6f837
commit 319a9b0f71
2 changed files with 9 additions and 10 deletions

View file

@ -4,7 +4,6 @@ use crate::sync::atomic::{
Ordering::{Acquire, Relaxed, Release},
};
use crate::sys::futex::{futex_wait, futex_wake, futex_wake_all};
use crate::sys_common::thread_info::current_thread_unique_ptr;
use crate::time::Duration;
pub type MovableMutex = Mutex;
@ -248,3 +247,12 @@ impl ReentrantMutex {
}
}
}
/// Get an address that is unique per running thread.
///
/// This can be used as a non-null usize-sized ID.
pub fn current_thread_unique_ptr() -> usize {
// 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))
}

View file

@ -30,15 +30,6 @@ impl ThreadInfo {
}
}
/// Get an address that is unique per running thread.
///
/// This can be used as a non-null usize-sized ID.
pub fn current_thread_unique_ptr() -> usize {
// 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> {
ThreadInfo::with(|info| info.thread.clone())
}