std: reduce code size of set_current

This commit is contained in:
joboet
2024-04-02 11:27:34 +02:00
parent e2cf2cb303
commit e7b5730d36

View File

@@ -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| match current.set(thread) {
Ok(()) => {}
Err(_) => rtabort!("should only be set once"),
});
}
/// Gets a handle to the thread that invokes it.