Implementation details.

Types

Name

Description

ElementWrapper

POD wrapper around an element (a void*) and an associated deleter. This must be POD, as we memset() it to 0 and memcpy() it around.

FakeUniqueInstance

No‐op stand‐in for UniqueInstance used when the tag is void.

SharedPtrDeleter

Deleter that owns a shared_ptr and disposes it on thread‐local destruction.

StaticMeta

Held in a singleton to track our global instances. We have one of these per "Tag", by default one for the whole system (Tag=void).

StaticMetaBase

Non‐templated base holding the shared thread‐local bookkeeping state.

ThreadEntry

Per‐thread entry. Each thread using a StaticMeta object has one. This is written from the owning thread only (under the lock), read from the owning thread (no lock necessary), and read from other threads (under the lock).

ThreadEntryList

Intrusive list of ThreadEntry objects for a single thread.

ThreadEntrySet

ThreadEntrySet is used to track all ThreadEntry that have a valid ElementWrapper for a particular TL id. The class provides no internal locking and caller must ensure safety of any access.

Type Aliases

Name

Description

ElementDisposeInfo

Cache the ptr + deleter info in ThreadEntrySet too. This allows accessAllThreads() to get to the per thread ptr without holding the StaticMeta's lock_. Eventually, the deleter info will be moved to the ThreadEntrySet alone, leaving only the ptr in the ElementWrapper. For now, the ElementDisposeInfo tracked in ThreadEntrySet is the same as ElementWrapper.

Variables

Name

Description

kEntryIDInvalid

Sentinel entry id representing an unallocated thread‐local slot.

Created with MrDocs