Add current_thread_unique_ptr() in std::sys_common.

This commit is contained in:
Mara Bos 2022-04-06 12:49:46 +02:00
parent b8f4cb6231
commit c62c8cb82d

View file

@ -30,6 +30,13 @@ 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 {
THREAD_INFO.with(|info| <*const _>::addr(info))
}
pub fn current_thread() -> Option<Thread> {
ThreadInfo::with(|info| info.thread.clone())
}