diff options
| author | joboet <jonasboettiger@icloud.com> | 2024-07-18 13:59:48 +0200 |
|---|---|---|
| committer | joboet <jonasboettiger@icloud.com> | 2024-10-02 18:04:21 +0200 |
| commit | d868fdce6b9ddef6abcc8de86b3ba8459def36a2 (patch) | |
| tree | b03a6ba5ff19869e0ebdeefb996e4387a5bb13b9 /library/std/src/sys/sync | |
| parent | 07f08ffb2dbc864d2127abedf7a5917b965c0a4b (diff) | |
| download | rust-d868fdce6b9ddef6abcc8de86b3ba8459def36a2.tar.gz rust-d868fdce6b9ddef6abcc8de86b3ba8459def36a2.zip | |
std: make `thread::current` available in all `thread_local!` destructors
Diffstat (limited to 'library/std/src/sys/sync')
| -rw-r--r-- | library/std/src/sys/sync/rwlock/queue.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/library/std/src/sys/sync/rwlock/queue.rs b/library/std/src/sys/sync/rwlock/queue.rs index 0e658328c2e..733f51cae8c 100644 --- a/library/std/src/sys/sync/rwlock/queue.rs +++ b/library/std/src/sys/sync/rwlock/queue.rs @@ -113,7 +113,7 @@ use crate::mem; use crate::ptr::{self, NonNull, null_mut, without_provenance_mut}; use crate::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed, Release}; use crate::sync::atomic::{AtomicBool, AtomicPtr}; -use crate::thread::{self, Thread}; +use crate::thread::{self, Thread, ThreadId}; // Locking uses exponential backoff. `SPIN_COUNT` indicates how many times the // locking operation will be retried. @@ -200,7 +200,9 @@ impl Node { fn prepare(&mut self) { // Fall back to creating an unnamed `Thread` handle to allow locking in // TLS destructors. - self.thread.get_or_init(|| thread::try_current().unwrap_or_else(Thread::new_unnamed)); + self.thread.get_or_init(|| { + thread::try_current().unwrap_or_else(|| Thread::new_unnamed(ThreadId::new())) + }); self.completed = AtomicBool::new(false); } |
