Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Move std::thread_local::* into std::thread #909

Merged
merged 2 commits into from
Mar 20, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions text/0000-move-thread-local-to-std-thread.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
- Feature Name: N/A
- Start Date: 2015-02-25
- RFC PR: (leave this empty)
- Rust Issue: (leave this empty)

# Summary

Move the contents of `std::thread_local` into `std::thread`. Fully
remove `std::thread_local` from the standard library.

# Motivation

Thread locals are directly related to threading. Combining the modules
would reduce the number of top level modules, combine related concepts,
and make browsing the docs easier. It also would have the potential to
slightly reduce the number of `use` statementsl

# Detailed design

The `std::thread_local` module would be renamed to `std::thread::local`.
All contents of the module would remain the same. This way, all thread
related code is combined in one module.

It would also allow using it as such:

```rust
use std::thread::{local, Thread};
```

# Drawbacks

It's pretty late in the 1.0 release cycle. This is a mostly bike
shedding level of a change. It may not be worth changing it at this
point and staying with two top level modules in `std`. Also, some users
may prefer to have more top level modules.

# Alternatives

Another strategy for moving `std::thread_local` would be to move it
directly into `std::thread` without scoping it in a dedicated module.
There are no naming conflicts, but the names would not be ideal anymore.
One way to mitigate would be to rename the types to something like
`LocalKey` and `LocalState`.

# Unresolved questions

The exact strategy for moving the contents into `std::thread`