refactor: + narrower interface for gc pointer forwarding
add AGCObjectVisitor, instead of requiring ACollector.
This commit is contained in:
parent
52fbf801ab
commit
8fe1871094
11 changed files with 45 additions and 27 deletions
|
|
@ -9,6 +9,7 @@
|
|||
#include <xo/type/Type.hpp>
|
||||
#include <xo/object2/DArray.hpp>
|
||||
#include <xo/alloc2/GCObjectConversion.hpp>
|
||||
#include <xo/alloc2/GCObjectVisitor.hpp>
|
||||
#include <xo/alloc2/GCObject.hpp>
|
||||
#include <xo/reflect/Reflect.hpp>
|
||||
#include <xo/alloc2/Allocator.hpp>
|
||||
|
|
@ -76,8 +77,9 @@ namespace xo {
|
|||
using Traits = detail::PmFnTraits<Fn>;
|
||||
|
||||
using ACollector = xo::mm::ACollector;
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using AGCObject = xo::mm::AGCObject;
|
||||
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using DArray = xo::scm::DArray;
|
||||
using Reflect = xo::reflect::Reflect;
|
||||
using TypeDescr = xo::reflect::TypeDescr;
|
||||
|
|
@ -134,7 +136,7 @@ namespace xo {
|
|||
/** @defgroup scm-primitive-gcobject-facet **/
|
||||
///@{
|
||||
Primitive * shallow_move(obj<ACollector> gc) noexcept;
|
||||
void forward_children(obj<ACollector> gc) noexcept;
|
||||
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
|
||||
///@}
|
||||
|
||||
private:
|
||||
|
|
@ -197,11 +199,12 @@ namespace xo {
|
|||
|
||||
template <typename Fn>
|
||||
void
|
||||
Primitive<Fn>::forward_children(obj<ACollector> gc) noexcept {
|
||||
{
|
||||
auto e = type_.to_facet<AGCObject>(); // FacetRegistry dep
|
||||
gc.forward_inplace(e.iface(), (void **)&(type_.data_));
|
||||
}
|
||||
Primitive<Fn>::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept {
|
||||
gc.visit_poly_child(&type_);
|
||||
//{
|
||||
// auto e = type_.to_facet<AGCObject>(); // FacetRegistry dep
|
||||
// gc.forward_inplace(e.iface(), (void **)&(type_.data_));
|
||||
//}
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ namespace xo {
|
|||
using size_type = xo::mm::AGCObject::size_type;
|
||||
using AAllocator = xo::mm::AGCObject::AAllocator;
|
||||
using ACollector = xo::mm::AGCObject::ACollector;
|
||||
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
|
||||
using Copaque = xo::mm::AGCObject::Copaque;
|
||||
using Opaque = xo::mm::AGCObject::Opaque;
|
||||
///@}
|
||||
|
|
@ -54,8 +55,10 @@ namespace xo {
|
|||
// non-const methods
|
||||
/** move instance using allocator **/
|
||||
static Opaque shallow_move(DPrimitive_gco_0 & self, obj<ACollector> gc) noexcept;
|
||||
/** during GC: forward immdiate children **/
|
||||
static void forward_children(DPrimitive_gco_0 & self, obj<ACollector> gc) noexcept;
|
||||
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
|
||||
Context: provides address of data pointer so it can be updated in place
|
||||
when @p fn invokes garbage collector reentry point **/
|
||||
static void visit_gco_children(DPrimitive_gco_0 & self, obj<AGCObjectVisitor> fn) noexcept;
|
||||
///@}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ namespace xo {
|
|||
using size_type = xo::mm::AGCObject::size_type;
|
||||
using AAllocator = xo::mm::AGCObject::AAllocator;
|
||||
using ACollector = xo::mm::AGCObject::ACollector;
|
||||
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
|
||||
using Copaque = xo::mm::AGCObject::Copaque;
|
||||
using Opaque = xo::mm::AGCObject::Opaque;
|
||||
///@}
|
||||
|
|
@ -54,8 +55,10 @@ namespace xo {
|
|||
// non-const methods
|
||||
/** move instance using allocator **/
|
||||
static Opaque shallow_move(DPrimitive_gco_1_gco & self, obj<ACollector> gc) noexcept;
|
||||
/** during GC: forward immdiate children **/
|
||||
static void forward_children(DPrimitive_gco_1_gco & self, obj<ACollector> gc) noexcept;
|
||||
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
|
||||
Context: provides address of data pointer so it can be updated in place
|
||||
when @p fn invokes garbage collector reentry point **/
|
||||
static void visit_gco_children(DPrimitive_gco_1_gco & self, obj<AGCObjectVisitor> fn) noexcept;
|
||||
///@}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ namespace xo {
|
|||
using size_type = xo::mm::AGCObject::size_type;
|
||||
using AAllocator = xo::mm::AGCObject::AAllocator;
|
||||
using ACollector = xo::mm::AGCObject::ACollector;
|
||||
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
|
||||
using Copaque = xo::mm::AGCObject::Copaque;
|
||||
using Opaque = xo::mm::AGCObject::Opaque;
|
||||
///@}
|
||||
|
|
@ -54,8 +55,10 @@ namespace xo {
|
|||
// non-const methods
|
||||
/** move instance using allocator **/
|
||||
static Opaque shallow_move(DPrimitive_gco_2_dict_string & self, obj<ACollector> gc) noexcept;
|
||||
/** during GC: forward immdiate children **/
|
||||
static void forward_children(DPrimitive_gco_2_dict_string & self, obj<ACollector> gc) noexcept;
|
||||
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
|
||||
Context: provides address of data pointer so it can be updated in place
|
||||
when @p fn invokes garbage collector reentry point **/
|
||||
static void visit_gco_children(DPrimitive_gco_2_dict_string & self, obj<AGCObjectVisitor> fn) noexcept;
|
||||
///@}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ namespace xo {
|
|||
using size_type = xo::mm::AGCObject::size_type;
|
||||
using AAllocator = xo::mm::AGCObject::AAllocator;
|
||||
using ACollector = xo::mm::AGCObject::ACollector;
|
||||
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
|
||||
using Copaque = xo::mm::AGCObject::Copaque;
|
||||
using Opaque = xo::mm::AGCObject::Opaque;
|
||||
///@}
|
||||
|
|
@ -54,8 +55,10 @@ namespace xo {
|
|||
// non-const methods
|
||||
/** move instance using allocator **/
|
||||
static Opaque shallow_move(DPrimitive_gco_2_gco_gco & self, obj<ACollector> gc) noexcept;
|
||||
/** during GC: forward immdiate children **/
|
||||
static void forward_children(DPrimitive_gco_2_gco_gco & self, obj<ACollector> gc) noexcept;
|
||||
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
|
||||
Context: provides address of data pointer so it can be updated in place
|
||||
when @p fn invokes garbage collector reentry point **/
|
||||
static void visit_gco_children(DPrimitive_gco_2_gco_gco & self, obj<AGCObjectVisitor> fn) noexcept;
|
||||
///@}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ namespace xo {
|
|||
using size_type = xo::mm::AGCObject::size_type;
|
||||
using AAllocator = xo::mm::AGCObject::AAllocator;
|
||||
using ACollector = xo::mm::AGCObject::ACollector;
|
||||
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
|
||||
using Copaque = xo::mm::AGCObject::Copaque;
|
||||
using Opaque = xo::mm::AGCObject::Opaque;
|
||||
///@}
|
||||
|
|
@ -54,8 +55,10 @@ namespace xo {
|
|||
// non-const methods
|
||||
/** move instance using allocator **/
|
||||
static Opaque shallow_move(DPrimitive_gco_3_dict_string_gco & self, obj<ACollector> gc) noexcept;
|
||||
/** during GC: forward immdiate children **/
|
||||
static void forward_children(DPrimitive_gco_3_dict_string_gco & self, obj<ACollector> gc) noexcept;
|
||||
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
|
||||
Context: provides address of data pointer so it can be updated in place
|
||||
when @p fn invokes garbage collector reentry point **/
|
||||
static void visit_gco_children(DPrimitive_gco_3_dict_string_gco & self, obj<AGCObjectVisitor> fn) noexcept;
|
||||
///@}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue