Closed alexcrichton closed 8 years ago
This reminds me of a Reader
monad and its local
method a lot. Specialisation of this monad to only work in TLS context sounds really obscure to me. Could this be generalised?
The stabilization of scoped TLS precludes the safe implementation of couroutines/fibers/green threads in external libraries.
Admittedly there are also problems with normal TLS, but they seem less terminal, and can probably be limited to causing unexpected behaviour or panics rather than outright memory unsafety with some changes.
Possible solutions:
All of the options have significant downsides, either due to complexity or runtime performance.
:bell: This issue is now entering its cycle final comment period to be deprecation in 1.8 :bell:
Scoped TLS can currently be built externally on crates.io if truly necessary, and otherwise it seems to be getting far less usage than originally anticipated.
Even though I was an initial advocate for (and proposer of) scoped TLS, I think it's good to deprecate it. One major limitation that I didn't fully appreciate at the time is that the T
of the variable must meet T: 'static
, which tends to rule out a lot of the uses I've had in mind. At least without some unsafety. e.g., in the compiler we do some tricks to put a &ty::ctxt<'tcx>
in there.
The libs team discussed this during triage yesterday and the conclusion was to deprecate
This is a tracking issue for the unstable
scoped_tls
feature in the standard library. The known open questions about this API are: