folly::hazptr_tc

hazptr_tc:

Synopsis

Declared in <folly/synchronization/HazptrThrLocal.h>

template<template<
    typename,
    typename,
    typename> typename Atom = atomic>
class hazptr_tc;

Description

Thread cache of hazptr_rec-s that belong to the default domain.

Uses a single dynamically-sized vector as the backing store. The hot paths (try_get, try_put) touch two cache lines for pure thread-local work with no atomics or contention: one for the vector metadata (data pointer, size, capacity) and count, and one for the actual entry being read or written.

A usage-aware decay mechanism gradually releases excess records (those beyond kCapacity) back to the domain when demand has subsided. Every kDecayThreshold fast-path puts when count exceeds kCapacity, the algorithm checks whether the excess was actively used during the window. If underutilized, both the record count and the allocation are shrunk, reclaiming memory. Active use (via try_put_slow) resets the tick counter and starts a new decay window.

Member Functions

NameDescription
hazptr_tc [constructor]Constructors
~hazptr_tc [destructor]Evicts all cached records on destruction.
operator= Assignment operators
allocated_capacity Returns the allocated capacity of the backing store.
count Returns the number of records currently cached.

Static Member Functions

NameDescription
min_capacity Returns the minimum guaranteed capacity of the cache.

Friends

NameDescription
folly::hazptr_tc_evict<Atom>
folly::hazptr_holderhazptr_holder
folly::hazptr_arrayhazptr_array
folly::hazptr_localGrants hazptr_local access to the thread cache internals.

Non-Member Functions

NameDescription
hazptr_tc_tlsAccess the thread-local hazard pointer cache.