xo-interpreter2 stack: + RuntimeContext.visit_pools() method
This commit is contained in:
parent
19906d582e
commit
c99ac53c72
10 changed files with 65 additions and 3 deletions
|
|
@ -18,11 +18,13 @@ namespace xo {
|
|||
class DSimpleRcx {
|
||||
public:
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using MemorySizeVisitor = xo::mm::MemorySizeVisitor;
|
||||
|
||||
public:
|
||||
DSimpleRcx(obj<AAllocator> mm) : allocator_{mm} {}
|
||||
|
||||
obj<AAllocator> allocator() const noexcept { return allocator_; }
|
||||
void visit_pools(const MemorySizeVisitor & visitor) const;
|
||||
|
||||
private:
|
||||
obj<AAllocator> allocator_;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
// includes (via {facet_includes})
|
||||
#include <xo/alloc2/Allocator.hpp>
|
||||
#include <xo/arena/MemorySizeInfo.hpp>
|
||||
#include <xo/facet/obj.hpp>
|
||||
#include <xo/facet/facet_implementation.hpp>
|
||||
#include <xo/facet/typeseq.hpp>
|
||||
|
|
@ -40,6 +41,8 @@ public:
|
|||
using Opaque = void *;
|
||||
/** xo memory allocator **/
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
/** function to visit memory pools **/
|
||||
using MemorySizeVisitor = xo::mm::MemorySizeVisitor;
|
||||
///@}
|
||||
|
||||
/** @defgroup scm-runtimecontext-methods **/
|
||||
|
|
@ -51,6 +54,8 @@ public:
|
|||
virtual void _drop(Opaque d) const noexcept = 0;
|
||||
/** default allocator to use for objects **/
|
||||
virtual obj<AAllocator> allocator(Copaque data) const noexcept = 0;
|
||||
/** invoke visitor for each distinct memory pool **/
|
||||
virtual void visit_pools(Copaque data, MemorySizeVisitor visitor) const = 0;
|
||||
|
||||
// nonconst methods
|
||||
///@}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ namespace scm {
|
|||
/** integer identifying a type **/
|
||||
using typeseq = xo::facet::typeseq;
|
||||
using AAllocator = ARuntimeContext::AAllocator;
|
||||
using MemorySizeVisitor = ARuntimeContext::MemorySizeVisitor;
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-runtimecontext-any-methods **/
|
||||
|
|
@ -60,6 +61,7 @@ namespace scm {
|
|||
|
||||
// const methods
|
||||
[[noreturn]] obj<AAllocator> allocator(Copaque) const noexcept override { _fatal(); }
|
||||
[[noreturn]] void visit_pools(Copaque, MemorySizeVisitor) const override { _fatal(); }
|
||||
|
||||
// nonconst methods
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ namespace xo {
|
|||
/** @defgroup scm-runtimecontext-dsimplercx-type-traits **/
|
||||
///@{
|
||||
using AAllocator = xo::scm::ARuntimeContext::AAllocator;
|
||||
using MemorySizeVisitor = xo::scm::ARuntimeContext::MemorySizeVisitor;
|
||||
using Copaque = xo::scm::ARuntimeContext::Copaque;
|
||||
using Opaque = xo::scm::ARuntimeContext::Opaque;
|
||||
///@}
|
||||
|
|
@ -48,6 +49,8 @@ namespace xo {
|
|||
// const methods
|
||||
/** default allocator to use for objects **/
|
||||
static obj<AAllocator> allocator(const DSimpleRcx & self) noexcept;
|
||||
/** invoke visitor for each distinct memory pool **/
|
||||
static void visit_pools(const DSimpleRcx & self, MemorySizeVisitor visitor);
|
||||
|
||||
// non-const methods
|
||||
///@}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <xo/alloc2/Allocator.hpp>
|
||||
#include <xo/arena/MemorySizeInfo.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
|
@ -29,6 +30,7 @@ namespace scm {
|
|||
/** integer identifying a type **/
|
||||
using typeseq = ARuntimeContext::typeseq;
|
||||
using AAllocator = ARuntimeContext::AAllocator;
|
||||
using MemorySizeVisitor = ARuntimeContext::MemorySizeVisitor;
|
||||
///@}
|
||||
|
||||
/** @defgroup scm-runtimecontext-xfer-methods **/
|
||||
|
|
@ -47,6 +49,9 @@ namespace scm {
|
|||
obj<AAllocator> allocator(Copaque data) const noexcept override {
|
||||
return I::allocator(_dcast(data));
|
||||
}
|
||||
void visit_pools(Copaque data, MemorySizeVisitor visitor) const override {
|
||||
return I::visit_pools(_dcast(data), visitor);
|
||||
}
|
||||
|
||||
// non-const methods
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ public:
|
|||
using DataPtr = Object::DataPtr;
|
||||
using typeseq = xo::reflect::typeseq;
|
||||
using AAllocator = ARuntimeContext::AAllocator;
|
||||
using MemorySizeVisitor = ARuntimeContext::MemorySizeVisitor;
|
||||
///@}
|
||||
|
||||
/** @defgroup scm-runtimecontext-router-ctors **/
|
||||
|
|
@ -56,6 +57,9 @@ public:
|
|||
obj<AAllocator> allocator() const noexcept {
|
||||
return O::iface()->allocator(O::data());
|
||||
}
|
||||
void visit_pools(MemorySizeVisitor visitor) const {
|
||||
return O::iface()->visit_pools(O::data(), visitor);
|
||||
}
|
||||
|
||||
// non-const methods (still const in router!)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue