Add current_thread_unique_ptr() in std::sys_common.
This commit is contained in:
parent
b8f4cb6231
commit
c62c8cb82d
1 changed files with 7 additions and 0 deletions
|
@ -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> {
|
pub fn current_thread() -> Option<Thread> {
|
||||||
ThreadInfo::with(|info| info.thread.clone())
|
ThreadInfo::with(|info| info.thread.clone())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue