9 ms·
It's super useful for many reasons: - to help make thread-unsafe APIs thread-safe E.g., errno, strtok(), and so on. - to store thread-private mutable
by cryptonector 6y ago
It's super useful for many reasons:
- to help make thread-unsafe APIs thread-safe
E.g., errno, strtok(), and so on.
- to store thread-private mutable globals
(Thread-locals are more like thread-globals.)
- to keep a reference/copy of global immutable
data that might get replaced in the middle of
a thread's handling of a request
- to keep contextual data that you can't retrofit
an API to pass explicitly (see also first item)
- spacechild1 6y agoPure Data made heavy use of thread local storage to turn the original application singleton (with lots of globals) into a threadsafe and reentrant library (libpd).