News for hackers. Stuff that matters.
Re:Rust – How do I create a global, mutable singleton? (2015) by cesarb on Wednesday July 22, 2020 @01:34PM (#23919462)
TLS has the additional downside that it makes it harder to move part of the processing to another thread, because the other thread will have a different TLS state. That is, once you have TLS, x() and thread::spawn(x).join() might no longer do the same thing. Using TLS creates thread affinity when one might not be expecting it.

(I've seen way too many times a thread-local being used as a way to smuggle extra parameters, often through several layers; inevitably, this breaks when one of the intermediate layers decides to run things in a separate thread pool.)

There are no comments on this comment yet.