Tracking issue for cleaning up std's thread_local implementation details #110897
Open
Description
opened on Apr 27, 2023
std::thread_local
, std::thread::local
, std::thread::local_impl
, std::sys_common::thread_local_key
, std::sys_common::thread_local_dtor
, std::sys::thread_local_key
, etc. etc. are all messy and form quite a confusing maze. Just look at this map I tried to draw of it all:
AAAaaaaAaa
Time to clean it up.
And maybe also fix some bugs while we're at it. ^^
- Initial name and module cleanup without touching implementation: Restructure and rename std thread_local internals to make it less of a maze #110861
- Remove unused
Key
type: Remove unused std::sys_common::thread_local_key::Key #110898 - Fix panic-in-drop handling
- Stop calling everything
Key
, because most of those things are actually not keys, and dropLazyKeyInner
- Reduce the amount of code in the
thread_local!{}
expansion. Make TLS accessors closures that return pointers #125525 - Use
*const T
rather than&'static T
when it's not really'static
: Make TLS accessors closures that return pointers #125525 - Clean up implementation more
- Store thread ID and stack guard range in thread locals without destructors (on platforms with
#[thread_local]
)?- Stack guard range: Refactor stack overflow handling #123265
- thread ID: Use ThreadId instead of TLS-address in
ReentrantLock
#124881
- Make
thread::current
thread local more efficient and make it available in (most) TLS destructors: std: makethread::current
available in allthread_local!
destructors #127912 - Detect stack overflow in TLS destructors: std: detect stack overflows in TLS destructors on UNIX #131282
Related issues to solve, maybe:
Activity