/** @file DCollector.hpp * * @author Roland Conybeare, Dec 2025 **/ #pragma once #include "ArenaConfig.hpp" #include "DArena.hpp" #include namespace xo { namespace mm { template using up = std::unique_ptr; struct CollectorConfig { using size_type = std::size_t; /** Configuration for collector spaces. * Will have at least {nursery,tenured} x {from,to} spaces. * Not using name_ member. **/ ArenaConfig arena_config_; /** Number of generations. * Must be at least 2. **/ uint32_t n_generation_ = 2; /** Number of promotion steps. * An object that survives this number of collections * advances to the next generation. **/ uint32_t n_survive_threshold_ = 2; /** Trigger garbage collection when to-space allocation for * generation g reaches gc_trigger_v_[g] **/ std::array gc_trigger_v_; /** true -> enable incremental collection. * false -> only do full collection. * * Incremental collection requires mutation logs. **/ bool allow_incremental_gc_ = true; /** If non-zero remember statistics for * the last @p stats_history_z_ collections. **/ uint32_t stats_history_z_ = false; /** true to enable debug logging **/ bool debug_flag_ = false; }; /** State associated with a single DCollector generation **/ struct Generation { Generation(uint8_t gen_id, up from_space, up to_space); ~Generation() = default; /** identity of this generation. Generations are numbered from * 0 (youngest) to N (oldest), with N <= c_max_generation **/ uint8_t gen_id_; /** from-space. empty between collection episodes. * During collection holds former to-space **/ up from_space_; /** to-space. New allocations occur here **/ up to_space_; }; struct DCollector { std::uint32_t std::array, c_max_generation> generations_[2]; }; } /*namespace mm*/ } /*namespace xo*/ /* end DCollector.hpp */