xo-alloc2: + Allocator.alloc_range() with DArena input
This commit is contained in:
parent
d8ed0d6235
commit
181ae9f12b
13 changed files with 158 additions and 59 deletions
|
|
@ -37,4 +37,4 @@ namespace xo {
|
|||
} /*namespace mm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end AllocIterator.hpp */
|
||||
/* end AAllocIterator.hpp */
|
||||
|
|
|
|||
|
|
@ -7,8 +7,10 @@
|
|||
|
||||
#include "AllocError.hpp"
|
||||
#include "AllocInfo.hpp"
|
||||
#include "xo/facet/facet_implementation.hpp"
|
||||
#include "xo/facet/typeseq.hpp"
|
||||
#include "AllocIterator.hpp"
|
||||
#include <xo/facet/obj.hpp>
|
||||
#include <xo/facet/facet_implementation.hpp>
|
||||
#include <xo/facet/typeseq.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace xo {
|
||||
|
|
@ -32,6 +34,8 @@ namespace xo {
|
|||
using value_type = std::byte *;
|
||||
/** object header, if configured **/
|
||||
using header_type = std::uint64_t;
|
||||
/** iterator range. These are forward iterators over allocs **/
|
||||
using range_type = std::pair<obj<AAllocIterator>, obj<AAllocIterator>>;
|
||||
///@}
|
||||
|
||||
/*
|
||||
|
|
@ -85,20 +89,21 @@ namespace xo {
|
|||
* Non-const @p d because may stash error details
|
||||
**/
|
||||
virtual AllocInfo alloc_info(Copaque d, value_type mem) const noexcept = 0;
|
||||
/** Ideally we want to control allocation for iterator here.
|
||||
* Awkward to describe to compiler since we don't have vt<AAllocator> yet.
|
||||
* OTOH iteration over allocs is a niche feature.
|
||||
* Consider alternatives:
|
||||
/** Ideally we want to control allocator for iterator here.
|
||||
* Awkward to supply to compiler since we don't have obj<AAllocator> yet.
|
||||
* OTOH iteration over allocs is a super-niche feature.
|
||||
*
|
||||
* Rejected alternatives:
|
||||
* - put begin/end in separate interface. e.g. extend AAllocator
|
||||
* - layer of indirection: begin/end return iterator factory.
|
||||
* Then allocator can be passed to iterator factory separately.
|
||||
* Helps because factory can be static
|
||||
* - abandon allocator support in this case. Instead will need to
|
||||
* reinstate uvt<AAllocIterator> (unique variant), use heap
|
||||
* - just pass DArena& for alloc-iterator-allocation
|
||||
*
|
||||
* @p mm is allocator for resulting iterator range
|
||||
**/
|
||||
//virtual facet::vt<AAllocIterator> begin(Copaque d, DArena & ialloc) const noexcept;
|
||||
// virtual obj<AAllocIterator> end() const noexcept = 0;
|
||||
virtual range_type alloc_range(Copaque d, DArena & mm) const noexcept = 0;
|
||||
|
||||
/** expand committed space in arena @p d
|
||||
* to size at least @p z
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
/** @file AllocIterator.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Dec 2025
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace xo {
|
||||
namespace mm {
|
||||
|
||||
/** @class AllocIterator
|
||||
* @brief iterator over arena allocations.
|
||||
*
|
||||
* Intended for instrumentation/diagnostics.
|
||||
* Not needed for normal operator
|
||||
**/
|
||||
struct AllocIterator {
|
||||
|
||||
};
|
||||
|
||||
} /*namespace mm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end AllocIterator.hpp */
|
||||
|
|
@ -45,6 +45,7 @@ namespace xo {
|
|||
[[noreturn]] AllocInfo alloc_info(Copaque, value_type) const noexcept override { _fatal(); }
|
||||
// defn in .cpp - problematic to require compiler know vt<AAllocIterator> defn here
|
||||
//[[noreturn]] facet::vt<AAllocIterator> begin(Copaque, DArena &) const noexcept override; // { _fatal(); }
|
||||
[[noreturn]] range_type alloc_range(Copaque, DArena &) const noexcept override { _fatal(); }
|
||||
|
||||
// non-const methods
|
||||
[[noreturn]] bool expand(Opaque, std::size_t) const noexcept override { _fatal(); }
|
||||
|
|
|
|||
|
|
@ -39,12 +39,13 @@ namespace xo {
|
|||
return I::contains(_dcast(d), p);
|
||||
}
|
||||
AllocError last_error(Copaque d) const noexcept override { return I::last_error(_dcast(d)); }
|
||||
|
||||
// non-const methods
|
||||
|
||||
AllocInfo alloc_info(Copaque d, value_type mem) const noexcept override {
|
||||
return I::alloc_info(_dcast(d), mem);
|
||||
}
|
||||
range_type alloc_range(Copaque d, DArena & mm) const noexcept override { return I::alloc_range(_dcast(d), mm); }
|
||||
|
||||
// non-const methods
|
||||
|
||||
bool expand(Opaque d,
|
||||
std::size_t z) const noexcept override { return I::expand(_dcast(d), z); }
|
||||
value_type alloc(Opaque d,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue