Skip to content

Commit

Permalink
std: reduce code size of set_current
Browse files Browse the repository at this point in the history
  • Loading branch information
joboet committed Apr 2, 2024
1 parent e2cf2cb commit b5ccebf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions library/std/src/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -684,9 +684,12 @@ thread_local! {

/// Sets the thread handle for the current thread.
///
/// Panics if the handle has been set already or when called from a TLS destructor.
/// Aborts if the handle has been set already to reduce code size.
pub(crate) fn set_current(thread: Thread) {
CURRENT.with(|current| current.set(thread).unwrap());
CURRENT.with(|current| {
rtassert!(current.get().is_none());
current.set(thread).unwrap();
});
}

/// Gets a handle to the thread that invokes it.
Expand Down

0 comments on commit b5ccebf

Please sign in to comment.