Skip to content

Commit

Permalink
Thread stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
terrarier2111 committed Jul 20, 2023
1 parent e1fc3f4 commit a821b47
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/thread_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,9 @@ cfg_if::cfg_if! {
/// Returns a thread ID for the current thread, allocating one if needed.
#[inline]
pub(crate) fn get() -> Thread {
let mut thread = MaybeUninit::uninit();
unsafe { ptr::copy_nonoverlapping(THREAD.get(), thread.as_mut_ptr(), 1) };
if likely(unsafe { thread.assume_init_ref().init }) {
unsafe { thread.assume_init() }
let thread = *THREAD.get();
if likely(thread.init) {
thread
} else {
get_slow()
}
Expand Down

0 comments on commit a821b47

Please sign in to comment.