xo-gc: + CollectorTypeRegistry for streamlined init
This commit is contained in:
parent
929c25a7a6
commit
93429becad
16 changed files with 319 additions and 6 deletions
|
|
@ -3,8 +3,11 @@
|
|||
set(SELF_LIB xo_gc)
|
||||
set(SELF_SRCS
|
||||
|
||||
CollectorTypeRegistry.cpp
|
||||
|
||||
ICollector_Any.cpp
|
||||
IGCObject_Any.cpp
|
||||
|
||||
IAllocator_DX1Collector.cpp
|
||||
ICollector_DX1Collector.cpp
|
||||
IAllocIterator_DX1CollectorIterator.cpp
|
||||
|
|
|
|||
45
xo-gc/src/gc/CollectorTypeRegistry.cpp
Normal file
45
xo-gc/src/gc/CollectorTypeRegistry.cpp
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/** @file CollectorTypeRegistry.cpp
|
||||
**/
|
||||
|
||||
#include "CollectorTypeRegistry.hpp"
|
||||
#include <xo/indentlog/scope.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace mm {
|
||||
CollectorTypeRegistry &
|
||||
CollectorTypeRegistry::instance() {
|
||||
static CollectorTypeRegistry s_instance;
|
||||
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
void
|
||||
CollectorTypeRegistry::register_types(init_function_type fn) {
|
||||
scope log(XO_DEBUG(true));
|
||||
|
||||
init_seq_v_.push_back(fn);
|
||||
}
|
||||
|
||||
bool
|
||||
CollectorTypeRegistry::install_types(obj<ACollector> gc) {
|
||||
scope log(XO_DEBUG(true));
|
||||
|
||||
bool ok = true;
|
||||
|
||||
size_t i = 0;
|
||||
size_t n = init_seq_v_.size();
|
||||
log && log("run n init steps", xtag("n", n));
|
||||
|
||||
for (const auto & fn : init_seq_v_) {
|
||||
log && log("do install fn (", i+1, "/", n, ")");
|
||||
|
||||
ok = ok & fn(gc);
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
} /*namespace mm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end CollectorTypeRegistry.cpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue