Loading...
Searching...
No Matches
tf::TaggedHead128 Struct Reference

tagged free-list head using a 128-bit (pointer, version) pair More...

#include <taskflow/utility/object_pool.hpp>

Public Types

using pointer_type = uintptr_t
 block address representation
 
using tag_type = uintptr_t
 ABA version counter representation.
 

Public Member Functions

 TaggedHead128 ()=default
 constructs a null, zero-tagged head
 
 TaggedHead128 (pointer_type p, tag_type t) noexcept
 constructs a head with an explicit block address and version counter
 
pointer_type get_ptr () const noexcept
 returns the stored block address
 
tag_type get_tag () const noexcept
 returns the ABA version counter
 

Public Attributes

pointer_type ptr {0}
 block address (reinterpret-cast to/from ObjectBlock*)
 
tag_type tag {0}
 ABA version counter; incremented on every push and pop.
 

Detailed Description

tagged free-list head using a 128-bit (pointer, version) pair

TaggedHead128 stores the free-list head pointer and an ABA version counter as two independent 64-bit words, yielding a 16-byte representation. std::atomic<TaggedHead128> requires a 128-bit compare-and-swap: CMPXCHG16B on x86-64 or CASP on ARMv8.1+. On platforms that lack a native 128-bit CAS (e.g. RISC-V, baseline ARMv8.0), the atomic falls back to a lock-based implementation — still correct, but no longer lock-free.

The full 64-bit version counter makes ABA wrap-around effectively impossible under any realistic workload.

// explicitly select the 128-bit head (this is also the default)
sharded fixed-size object allocator with a lock-free hot path
Definition object_pool.hpp:320
See also
TaggedHead64 for an 8-byte alternative that is lock-free on all 64-bit platforms at the cost of a narrower version counter.

Constructor & Destructor Documentation

◆ TaggedHead128()

tf::TaggedHead128::TaggedHead128 ( pointer_type p,
tag_type t )
inlinenoexcept

constructs a head with an explicit block address and version counter

Parameters
pblock address as uintptr_t
tABA version counter

The documentation for this struct was generated from the following file: