TheAtlasEngine
 
Loading...
Searching...
No Matches
atlas::memory::detail::ref_info Struct Reference

Control block for reference counting - type erased. More...

#include <memory.hpp>

Public Types

using destroy_fn_t = size_t(void const *)
 Destroy function for ref counted object.
 

Public Attributes

std::pmr::polymorphic_allocator allocator
 Initialize to 1 since creation implies a reference.
 
destroy_fn_tdestroy
 
std::atomic< int32_t > strong_count = 1
 
std::atomic< int32_t > weak_count = 0
 

Detailed Description

Control block for reference counting - type erased.

This structure manages the lifetime of reference-counted objects by tracking strong and weak references. It also stores the memory allocator and destroy function used to clean up the object when no more references exist.

Member Typedef Documentation

◆ destroy_fn_t

using atlas::memory::detail::ref_info::destroy_fn_t = size_t(void const*)

Destroy function for ref counted object.

Always returns the total size of the object wrapped in a ref count object. Thus the size should normally be greater than sizeof(T). Expect sizeof(T) + sizeof(ref_info) and anything else the ref count object may contain.

If a nullptr is passed to the destroy function, it returns the object size but does not destroy the object.


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