Skip to content

Commit 2f46de2

Browse files
committed
Add current_thread_unique_ptr() in std::sys_common.
1 parent 8cd6080 commit 2f46de2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

library/std/src/sys_common/thread_info.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ impl ThreadInfo {
3030
}
3131
}
3232

33+
/// Get an address that is unique per running thread.
34+
///
35+
/// This can be used as a non-null usize-sized ID.
36+
pub fn current_thread_unique_ptr() -> usize {
37+
THREAD_INFO.with(|info| <*const _>::addr(info))
38+
}
39+
3340
pub fn current_thread() -> Option<Thread> {
3441
ThreadInfo::with(|info| info.thread.clone())
3542
}

0 commit comments

Comments
 (0)