Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for `thread_local_state` stabilization #27716
Comments
aturon
added
T-libs
B-unstable
labels
Aug 12, 2015
alexcrichton
added
the
E-easy
label
Aug 13, 2015
Manishearth
removed
the
E-easy
label
Oct 2, 2015
This comment has been minimized.
This comment has been minimized.
|
Nominating for stabilization in 1.6. |
aturon
added
the
I-nominated
label
Nov 4, 2015
This comment has been minimized.
This comment has been minimized.
|
The libs team decided to not move this into FCP, some worries around this being:
|
alexcrichton
removed
the
I-nominated
label
Nov 5, 2015
alexcrichton
added
the
I-nominated
label
Jan 27, 2016
This comment has been minimized.
This comment has been minimized.
|
Although I nominated this for 1.8, libs decided to remove the nomination as I forgot that the reason this is not in FCP yet is because you hit TLS twice when querying the state. |
alexcrichton
removed
the
I-nominated
label
Jan 29, 2016
This comment has been minimized.
This comment has been minimized.
|
I think this would be better expressed like |
This comment has been minimized.
This comment has been minimized.
|
See also: rust-lang/rfcs#2030 |
This comment has been minimized.
This comment has been minimized.
|
PR for |
bors
added a commit
that referenced
this issue
Jul 12, 2017
bors
added a commit
that referenced
this issue
Jul 12, 2017
bors
added a commit
that referenced
this issue
Jul 13, 2017
Mark-Simulacrum
added
the
C-tracking-issue
label
Jul 22, 2017
This comment has been minimized.
This comment has been minimized.
|
The documenation for
But then it also mentions:
Do we really want to make the first guarantee? Is it not reasonable for |
This comment has been minimized.
This comment has been minimized.
|
+1 to that. |
This comment has been minimized.
This comment has been minimized.
|
@stjepang sounds reasonable to me! |
stjepang
referenced this issue
Oct 17, 2017
Merged
Docs: a LocalKey might start in the Valid state #45340
This comment has been minimized.
This comment has been minimized.
This issue should be resolved now that we have
|
This comment has been minimized.
This comment has been minimized.
In #43491, I proposed adding a fourth |
kennytm
added a commit
to kennytm/rust
that referenced
this issue
Oct 18, 2017
This comment has been minimized.
This comment has been minimized.
|
Until we decide what to do with |
pitdicker
referenced this issue
Dec 18, 2017
Closed
Fallback to the global allocator when the TLS var has been deinitialized. #154
Mark-Simulacrum
added
the
I-nominated
label
Jan 15, 2018
This comment has been minimized.
This comment has been minimized.
|
Nominating. I propose that we stabilize the |
This comment has been minimized.
This comment has been minimized.
|
I agree with @Mark-Simulacrum's assessment and would be ok stabilizing @rfcbot fcp merge |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Jan 23, 2018
•
|
Team member @alexcrichton has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
rfcbot
added
the
proposed-final-comment-period
label
Jan 23, 2018
alexcrichton
removed
the
I-nominated
label
Jan 23, 2018
rfcbot
added
final-comment-period
and removed
proposed-final-comment-period
labels
Feb 14, 2018
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Feb 14, 2018
|
|
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Feb 24, 2018
|
The final comment period is now complete. |
Manishearth
added a commit
to Manishearth/rust
that referenced
this issue
Mar 1, 2018
Manishearth
added a commit
to Manishearth/rust
that referenced
this issue
Mar 1, 2018
bors
closed this
in
#48585
Mar 2, 2018
This comment has been minimized.
This comment has been minimized.
|
I regret stabilizing So the signature of pub fn try_with<F, R>(&'static self, f: F) -> Result<R, AccessError>
where
F: FnOnce(&T) -> R;We should've gone with the following instead: pub fn try_with<F, R>(&'static self, f: F) -> R
where
F: FnOnce(Result<&T, AccessError>) -> R;Why? I have a situation with this helper function: pub fn with_context<F, R>(f: F) -> R
where
F: FnOnce(&Arc<Context>) -> R,
{
CONTEXT.try_with(|cx| f(cx)).unwrap_or_else(|_| f(&Context::new()))
}Unfortunately, the helper function doesn't compile: error[E0382]: capture of moved value: `f`
--> src/internal/context.rs:162:53
|
162 | CONTEXT.try_with(|cx| f(cx)).unwrap_or_else(|_| f(&Context::new()))
| ---- ^ value captured here after move
| |
| value moved (into closure) here
|
= note: move occurs because `f` has type `F`, which does not implement the `Copy` traitSo Had we gone with the other signature for pub fn with_context<F, R>(f: F) -> R
where
F: FnOnce(&Arc<Context>) -> R,
{
CONTEXT.try_with(|cx| {
match cx {
Ok(cx) => f(cx),
Err(..) => f(&Context::new()),
}
})
} |
aturon commentedAug 12, 2015
This feature allows you to query a thread-local variable for its state: http://static.rust-lang.org/doc/master/std/thread/enum.LocalKeyState.html, which will then tell you what may happen if you try to read from the variable.
The functionality is somewhat niche, but occasionally essential. The APIs appear to be in pretty decent shape as-is.
cc @alexcrichton