Skip to content

Commit 50ff468

Browse files
committed
Focus on a single std::thread_local renaming strategy
1 parent 1e5c603 commit 50ff468

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

text/0000-move-thread-local-to-std-thread.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,21 @@ remove `std::thread_local` from the standard library.
1111
# Motivation
1212

1313
Thread locals are directly related to threading. Combining the modules
14-
would reduce the number of top level modules, making browsing the docs
15-
easier as well as reduce the number of `use` statements.
14+
would reduce the number of top level modules, combine related concepts,
15+
and make browsing the docs easier. It also would have the potential to
16+
slightly reduce the number of `use` statementsl
1617

1718
# Detailed design
1819

19-
The goal is to move the contents of `std::thread_local` into
20-
`std::thread`. There are a few possible strategies that could be used to
21-
achieve this.
20+
The `std::thread_local` module would be renamed to `std::thread::local`.
21+
All contents of the module would remain the same. This way, all thread
22+
related code is combined in one module.
2223

23-
One option would be to move the contents as is into `std::thread`. This
24-
would leave `Key` and `State` as is. There would be no naming conflict,
25-
but the names would be less ideal since the containing module is not
26-
directly related to thread locals anymore. This could be handled by
27-
renaming the types to something like `LocalKey` and `LocalState`.
24+
It would also allow using it as such:
2825

29-
Another option would be to move the contents into a dedicated sub module
30-
such as `std::thread::local`. This would mean some code would still have
31-
an extra `use` statement for pulling in thread local related types, but
32-
it would also enable doing:
33-
34-
`use std::thread::{local, Thread};`
26+
```rust
27+
use std::thread::{local, Thread};
28+
```
3529

3630
# Drawbacks
3731

@@ -42,7 +36,11 @@ may prefer to have more top level modules.
4236

4337
# Alternatives
4438

45-
Leaving `std::thread_local` in its own module.
39+
Another strategy for moving `std::thread_local` would be to move it
40+
directly into `std::thread` without scoping it in a dedicated module.
41+
There are no naming conflicts, but the names would not be ideal anymore.
42+
One way to mitigate would be to rename the types to something like
43+
`LocalKey` and `LocalState`.
4644

4745
# Unresolved questions
4846

0 commit comments

Comments
 (0)