std: Second pass stabilization for thread_local #20354
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit performs a second pass over the
std::thread_local
module. Most ofthe functionality remains explicitly unstable, but the specific actions taken
were:
thread_local
is now stablethread_local!
is now stablethread_local::Key
is now stablethread_local::Key::with
is now stablethread_local::Key::destroyed
is deprecated in favor of a more generalstate
functionthread_local::Key::state
was added to query the three states that a key canbe in: uninitialized, valid, or destroyed. This function, and the
corresponding
State
enum, are both marked unstable as we may wish to expandit later on.
thread_local::scoped
is entirely unstable. There hasn't been a whole lot ofusage of this module in the standard distribution, so it remains unstable at
this time.
Note that while the structure
Key
is marked stable, it is currently forced toexpose all of its implementation details due to the use of
construction-via-macro. The use of construction-via-macro is currently required
in order to place the
#[thread_local]
attribute on static in aplatform-specific manner. These stability attributes were assigned assuming that
it will be acceptable to tweak the implementation of
Key
in the future.