diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2022-04-06 22:12:47 +0200 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2022-04-12 08:44:39 +0200 |
| commit | 319a9b0f71d21409858297357bc047fb7a6ba27f (patch) | |
| tree | dd083a859fe622eca37b05740c3a75f0ba9cb8b8 | |
| parent | ebebe6f837b3499efb5cf1eb95e7eeffbc5e477a (diff) | |
| download | rust-319a9b0f71d21409858297357bc047fb7a6ba27f.tar.gz rust-319a9b0f71d21409858297357bc047fb7a6ba27f.zip | |
Move current_thread_unique_ptr to the only module that uses it.
| -rw-r--r-- | library/std/src/sys/unix/locks/futex.rs | 10 | ||||
| -rw-r--r-- | library/std/src/sys_common/thread_info.rs | 9 |
2 files changed, 9 insertions, 10 deletions
diff --git a/library/std/src/sys/unix/locks/futex.rs b/library/std/src/sys/unix/locks/futex.rs index f49fbda0d82..1df7b532546 100644 --- a/library/std/src/sys/unix/locks/futex.rs +++ b/library/std/src/sys/unix/locks/futex.rs @@ -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)) +} diff --git a/library/std/src/sys_common/thread_info.rs b/library/std/src/sys_common/thread_info.rs index b8f2e658214..38c9e50009a 100644 --- a/library/std/src/sys_common/thread_info.rs +++ b/library/std/src/sys_common/thread_info.rs @@ -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()) } |
