diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2022-04-06 12:49:46 +0200 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2022-04-12 08:41:42 +0200 |
| commit | c62c8cb82d18ee36bc47e12e5722d51cc011f133 (patch) | |
| tree | e960cf371faefa1c5db9711e24a20ee9c83c6fc0 /library/std/src | |
| parent | b8f4cb6231dc7d4ff9afe62de798af0dc18ae835 (diff) | |
| download | rust-c62c8cb82d18ee36bc47e12e5722d51cc011f133.tar.gz rust-c62c8cb82d18ee36bc47e12e5722d51cc011f133.zip | |
Add current_thread_unique_ptr() in std::sys_common.
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/sys_common/thread_info.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/library/std/src/sys_common/thread_info.rs b/library/std/src/sys_common/thread_info.rs index 38c9e50009a..cd570dca0ff 100644 --- a/library/std/src/sys_common/thread_info.rs +++ b/library/std/src/sys_common/thread_info.rs @@ -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()) } |
