perthread
Perthread, or per-thread storage, is data that is allocated separately for each thread in a multi-threaded program. Each thread has its own copy, which is invisible to other threads unless explicitly accessed through thread-local handles. Perthread data persists for the lifetime of the thread and is automatically isolated from other threads.
Common implementations rely on thread-local storage (TLS). In C++, the thread_local keyword declares a variable with
Use cases include per-thread caches, per-thread logging buffers, per-thread errno-like state, and avoiding synchronization when shared
Advantages include reduced contention and avoidance of locks for thread-specific data; however, per-thread data increases overall
Related concepts include thread-local storage, thread-specific data, and the various language and OS APIs for TLS.