xo-ordinaltree: start work on gc-aware Key,Value in rbtree
This commit is contained in:
parent
3d06980b42
commit
528a772ea2
7 changed files with 48 additions and 6 deletions
|
|
@ -90,9 +90,8 @@ add_subdirectory(xo-unit)
|
|||
add_subdirectory(xo-pyunit)
|
||||
add_subdirectory(xo-callback)
|
||||
add_subdirectory(xo-alloc)
|
||||
add_subdirectory(xo-ordinaltree)
|
||||
#
|
||||
add_subdirectory(xo-object)
|
||||
add_subdirectory(xo-ordinaltree)
|
||||
#
|
||||
add_subdirectory(xo-webutil)
|
||||
add_subdirectory(xo-pywebutil)
|
||||
|
|
|
|||
|
|
@ -5,15 +5,16 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "xo/reflect/TaggedPtr.hpp"
|
||||
#include "IAlloc.hpp"
|
||||
#include "xo/allocutil/IObject.hpp"
|
||||
#include "xo/reflect/TaggedPtr.hpp"
|
||||
#include "xo/allocutil/ObjectVisitor.hpp"
|
||||
#include "xo/allocutil/gc_ptr.hpp"
|
||||
#include <concepts>
|
||||
#include <cstdint>
|
||||
|
||||
namespace xo {
|
||||
namespace gc {
|
||||
class IAlloc;
|
||||
class GC;
|
||||
class ObjectStatistics;
|
||||
};
|
||||
|
|
@ -147,6 +148,18 @@ namespace xo {
|
|||
reinterpret_cast<IObject *>(rhs.ptr()));
|
||||
}
|
||||
|
||||
namespace gc {
|
||||
template <typename T>
|
||||
class ObjectVisitor<gp<T>> {
|
||||
public:
|
||||
void forward_children(gp<T> & target,
|
||||
IAlloc * gc)
|
||||
{
|
||||
Object::_forward_inplace(target, gc);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
std::ostream &
|
||||
operator<< (std::ostream & os, gp<Object> x);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
|
||||
namespace xo {
|
||||
namespace gc { class IAlloc; }
|
||||
|
|
|
|||
|
|
@ -36,8 +36,9 @@ namespace xo {
|
|||
**/
|
||||
template <typename T>
|
||||
class ObjectVisitor {
|
||||
void forward_children(T & target,
|
||||
IAlloc * gc) { (void)target; (void)gc; }
|
||||
// public:
|
||||
// void forward_children(T & target,
|
||||
// IAlloc * gc) { (void)target; (void)gc; }
|
||||
};
|
||||
|
||||
#define XO_TRIVIAL_OBJECT_VISITOR(TYPE) \
|
||||
|
|
|
|||
|
|
@ -69,6 +69,8 @@ namespace xo {
|
|||
* and 2nd-highest bit clear.
|
||||
*
|
||||
* @text
|
||||
* 1 byte
|
||||
* <------>
|
||||
* bits: 76543210
|
||||
* 10______
|
||||
* @endtext
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ add_test(NAME ${SELF_EXE} COMMAND ${SELF_EXE})
|
|||
# internal dependencies: refcnt, ...
|
||||
|
||||
xo_self_dependency(${SELF_EXE} xo_ordinaltree)
|
||||
xo_dependency(${SELF_EXE} xo_object)
|
||||
xo_dependency(${SELF_EXE} xo_alloc)
|
||||
xo_dependency(${SELF_EXE} refcnt)
|
||||
xo_dependency(${SELF_EXE} indentlog)
|
||||
|
|
|
|||
|
|
@ -6,13 +6,16 @@
|
|||
#include "random_tree_ops.hpp"
|
||||
#include "xo/ordinaltree/RedBlackTree.hpp"
|
||||
#include "xo/ordinaltree/rbtree/SumReduce.hpp"
|
||||
#include "xo/object/String.hpp"
|
||||
#include "xo/alloc/GC.hpp"
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::gc::GC;
|
||||
using xo::obj::String;
|
||||
using xo::tree::RedBlackTree;
|
||||
using xo::tree::SumReduce;
|
||||
using xo::tree::detail::Node;
|
||||
|
||||
using utest::TreeUtil;
|
||||
|
||||
|
|
@ -308,6 +311,28 @@ namespace xo {
|
|||
}
|
||||
}
|
||||
|
||||
} // TEST_CASE(rbtree-gc-1)
|
||||
|
||||
TEST_CASE("gp-string-key-allocate", "[gc]")
|
||||
{
|
||||
up<GC> gc = GC::make(
|
||||
{
|
||||
.initial_nursery_z_ = 1024,
|
||||
.initial_tenured_z_ = 4096,
|
||||
.incr_gc_threshold_ = 512,
|
||||
.full_gc_threshold_ = 512,
|
||||
.debug_flag_ = true
|
||||
}
|
||||
);
|
||||
|
||||
gp<String> s0 = String::copy(gc.get(), "hello");
|
||||
REQUIRE(s0->length() == 5);
|
||||
|
||||
//using Allocator = xo::gc::allocator<gp<String>>;
|
||||
//using NodeAllocator = xo::gc::allocator<std::pair<const gp<String>, int>>;
|
||||
//using RbNode = Node<gp<String>, int, SumReduce<int>, NodeAllocator>;
|
||||
|
||||
REQUIRE(true);
|
||||
}
|
||||
|
||||
} /*namespace ut*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue