xo-alloc2: DX1CollectorIterator infra [WIP]
This commit is contained in:
parent
59c0311ed7
commit
bf27314688
30 changed files with 1041 additions and 176 deletions
|
|
@ -6,6 +6,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "alloc/AllocInfo.hpp"
|
||||
#include "cmpresult.hpp"
|
||||
#include <xo/facet/obj.hpp>
|
||||
|
||||
namespace xo {
|
||||
|
|
@ -19,7 +20,8 @@ namespace xo {
|
|||
/** @class AAllocIterator
|
||||
* @brief Abstract facet for iterating over allocs
|
||||
*
|
||||
* Iterator refers to an AllocInfo instance.
|
||||
* Iterator refers to an AllocInfo instance
|
||||
* Only supporting forward-allocator.
|
||||
**/
|
||||
struct AAllocIterator {
|
||||
using obj_AAllocIterator = xo::facet::obj<AAllocIterator>;
|
||||
|
|
@ -29,13 +31,11 @@ namespace xo {
|
|||
/** retrieve AllocInfo for current iterator position
|
||||
**/
|
||||
virtual AllocInfo deref(Copaque d) const noexcept = 0;
|
||||
/** compare alloc iterators @p d and @p other for equality **/
|
||||
virtual int compare(Copaque d,
|
||||
const obj_AAllocIterator & other) const noexcept = 0;
|
||||
/** compare alloc iterators @p d and @p other **/
|
||||
virtual cmpresult compare(Copaque d,
|
||||
const obj_AAllocIterator & other) const noexcept = 0;
|
||||
/** advance iterator to next position **/
|
||||
virtual void next(Opaque d) const noexcept = 0;
|
||||
/** retreat iterator to previous position **/
|
||||
virtual void prev(Opaque d) const noexcept = 0;
|
||||
};
|
||||
} /*namespace mm*/
|
||||
} /*namespace xo*/
|
||||
|
|
|
|||
|
|
@ -29,6 +29,14 @@ namespace xo {
|
|||
alloc_info_disabled,
|
||||
/** attempt to call alloc_info for address not owned by allocator **/
|
||||
alloc_info_address,
|
||||
/** for example: alloc iteration not supported in arenas with
|
||||
* AllocConfig.store_header_flag_ = false
|
||||
**/
|
||||
alloc_iterator_not_supported,
|
||||
/** attempt to deref an iterator that does not refer to an alloc **/
|
||||
alloc_iterator_deref,
|
||||
/** attempt to advance an iterator that does not refer to an alloc **/
|
||||
alloc_iterator_next,
|
||||
};
|
||||
|
||||
struct AllocError {
|
||||
|
|
|
|||
|
|
@ -17,20 +17,6 @@ namespace xo {
|
|||
|
||||
explicit AllocHeader(repr_type x) : repr_{x} {}
|
||||
|
||||
#ifdef OBSOLETE
|
||||
std::uint32_t tseq(const AllocHeaderConfig & cfg) const noexcept {
|
||||
return cfg.tseq(repr_);
|
||||
}
|
||||
|
||||
std::uint32_t age(const AllocHeaderConfig & cfg) const noexcept {
|
||||
return cfg.age(repr_);
|
||||
}
|
||||
|
||||
size_type size(const AllocHeaderConfig & cfg) const noexcept {
|
||||
return cfg.size(repr_);
|
||||
}
|
||||
#endif
|
||||
|
||||
repr_type repr_;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,11 @@ namespace xo {
|
|||
p_guard_hi_{p_guard_hi} {}
|
||||
|
||||
/** error when alloc-header not configured **/
|
||||
static AllocInfo error_not_configured(AllocHeaderConfig * p_cfg) {
|
||||
static AllocInfo error_not_configured(const AllocHeaderConfig * p_cfg) {
|
||||
return AllocInfo(p_cfg, nullptr, nullptr, nullptr);
|
||||
}
|
||||
/** error on deref empty iterator **/
|
||||
static AllocInfo error_invalid_iterator(const AllocHeaderConfig * p_cfg) {
|
||||
return AllocInfo(p_cfg, nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
||||
|
|
@ -46,6 +50,8 @@ namespace xo {
|
|||
std::uint32_t age() const noexcept { return p_config_->age (*p_header_); }
|
||||
/** Allocation size (including allocator-supplied padding) **/
|
||||
size_type size() const noexcept { return p_config_->size(*p_header_); }
|
||||
/** Payload for this allocation. This is the memory available to application **/
|
||||
span_type payload() const noexcept;
|
||||
/** Guard bytes immediately following allocation **/
|
||||
span_type guard_hi() const noexcept;
|
||||
/** Number of guard bytes **/
|
||||
|
|
|
|||
|
|
@ -27,12 +27,11 @@ namespace xo {
|
|||
|
||||
// const methods
|
||||
[[noreturn]] AllocInfo deref(Copaque) const noexcept override { _fatal(); }
|
||||
[[noreturn]] int compare(Copaque,
|
||||
const obj_AAllocIterator &) const noexcept override { _fatal(); }
|
||||
[[noreturn]] cmpresult compare(Copaque,
|
||||
const obj_AAllocIterator &) const noexcept override { _fatal(); }
|
||||
|
||||
// non-const methods
|
||||
[[noreturn]] void next(Opaque) const noexcept override { _fatal(); }
|
||||
[[noreturn]] void prev(Opaque) const noexcept override { _fatal(); }
|
||||
|
||||
private:
|
||||
[[noreturn]] static void _fatal();
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
* @author Roland Conybeare, Dec 2025
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "AAllocIterator.hpp"
|
||||
|
||||
namespace xo {
|
||||
|
|
@ -27,15 +29,14 @@ namespace xo {
|
|||
int32_t _typeseq() const noexcept override { return s_typeseq; }
|
||||
AllocInfo deref(Copaque d)
|
||||
const noexcept override { return I::deref(_dcast(d)); }
|
||||
int compare(Copaque d,
|
||||
const obj_AAllocIterator & other)
|
||||
cmpresult compare(Copaque d,
|
||||
const obj_AAllocIterator & other)
|
||||
const noexcept override
|
||||
{ return I::compare(_dcast(d), other); }
|
||||
|
||||
// non-const methods
|
||||
|
||||
void next(Opaque d) const noexcept override { I::prev(_dcast(d)); }
|
||||
void prev(Opaque d) const noexcept override { I::next(_dcast(d)); }
|
||||
void next(Opaque d) const noexcept override { I::next(_dcast(d)); }
|
||||
|
||||
private:
|
||||
using I = Impl;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
**/
|
||||
|
||||
#include "AAllocIterator.hpp"
|
||||
#include <xo/facet/RRouter.hpp"
|
||||
#include <xo/facet/RRouter.hpp>
|
||||
//#include <string>
|
||||
|
||||
namespace xo {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue