We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
set_current
1 parent e2cf2cb commit b5ccebfCopy full SHA for b5ccebf
library/std/src/thread/mod.rs
@@ -684,9 +684,12 @@ thread_local! {
684
685
/// Sets the thread handle for the current thread.
686
///
687
-/// 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.
688
pub(crate) fn set_current(thread: Thread) {
689
- CURRENT.with(|current| current.set(thread).unwrap());
+ CURRENT.with(|current| {
690
+ rtassert!(current.get().is_none());
691
+ current.set(thread).unwrap();
692
+ });
693
}
694
695
/// Gets a handle to the thread that invokes it.
0 commit comments