From 834ddf1b9a9c1aa18fb6a1b00fe6f59251a97480 Mon Sep 17 00:00:00 2001 From: Tianqi Chen Date: Mon, 11 Nov 2019 10:09:29 -0800 Subject: [PATCH] [RUNTIME][REFACTOR] Use object protocol to support runtime::Module (#4289) Previously runtime::Module was supported using shared_ptr. This PR refactors the codebase to use the Object protocol. It will open doors to allow easier interpolation between Object containers and module in the future. --- src/dpi/module.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/dpi/module.cc b/src/dpi/module.cc index 6ef6af8fbcbd..27161c4b1bf8 100644 --- a/src/dpi/module.cc +++ b/src/dpi/module.cc @@ -226,7 +226,7 @@ class DPIModule final : public DPIModuleNode { PackedFunc GetFunction( const std::string& name, - const std::shared_ptr& sptr_to_self) final { + const ObjectPtr& sptr_to_self) final { if (name == "WriteReg") { return TypedPackedFunc( [this](int addr, int value){ @@ -413,8 +413,7 @@ class DPIModule final : public DPIModuleNode { }; Module DPIModuleNode::Load(std::string dll_name) { - std::shared_ptr n = - std::make_shared(); + auto n = make_object(); n->Init(dll_name); return Module(n); }