4 ms·
I've generally found that thread-local storage is easily misused. My general rule of thumb is to avoid thread-locals wherever possible, but if they are required
by terrelln 8y ago
I've generally found that thread-local storage is easily misused. My general rule of thumb is to avoid thread-locals wherever possible, but if they are required keep thread-local state constant sized, not one per object. The memory usage can grow rapidly when your library is used with many objects and many threads. In places where you would want one thread-local per object, instead try core-locals.
- quotemstr 8y agoSure. Sometimes, people use TLS to implement Lisp-style "dynamic scope" in an effort to reduce the amount of information passed from call-frame to call-frame via explict parameters. This approach suffers from the same drawback that dynamic scope does, and it's usually (but not always!) better to be explicit.
- saagarjha 8y ago> TLS Not the clearest abbreviation ;)