From 33b8572efcb898116e9cf97e792e49ac1cbbace9 Mon Sep 17 00:00:00 2001 From: Matthieu Dorier Date: Mon, 6 Aug 2018 14:14:05 +0200 Subject: [PATCH] added possibility to create endpoint and provider_handle from an hg_addr_t --- include/thallium/endpoint.hpp | 14 ++++++++++---- include/thallium/provider_handle.hpp | 10 ++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/include/thallium/endpoint.hpp b/include/thallium/endpoint.hpp index 1b5c87e..0e64c66 100644 --- a/include/thallium/endpoint.hpp +++ b/include/thallium/endpoint.hpp @@ -40,6 +40,8 @@ private: engine* m_engine; hg_addr_t m_addr; +public: + /** * @brief Constructor. Made private since endpoint instances * can only be created using engine::lookup. @@ -47,10 +49,14 @@ private: * @param e Engine that created the endpoint. * @param addr Mercury address. */ - endpoint(engine& e, hg_addr_t addr) - : m_engine(&e), m_addr(addr) {} - -public: + endpoint(engine& e, hg_addr_t addr, bool take_ownership=true) + : m_engine(&e), m_addr(HG_ADDR_NULL) { + if(take_ownership) { + m_addr = addr; + } else { + margo_addr_dup(m_engine->m_mid, addr, &m_addr); + } + } /** * @brief Default constructor defined so that endpoints can diff --git a/include/thallium/provider_handle.hpp b/include/thallium/provider_handle.hpp index e10ef8b..f9a7afb 100644 --- a/include/thallium/provider_handle.hpp +++ b/include/thallium/provider_handle.hpp @@ -28,6 +28,16 @@ private: public: + /** + * @brief Constructor from a HG address. + * + * @param e engine. + * @param addr Address to encapsulate. + * @param provider_id provider id. + */ + provider_handle(engine& e, hg_addr_t addr, uint16_t provider_id=0, bool take_ownership=true) + : endpoint(e, addr, take_ownership), m_provider_id(provider_id) {} + /** * @brief Constructor. * -- 2.26.2