From 721c78988a4d9e214b3baeba587097c22f185e34 Mon Sep 17 00:00:00 2001 From: rnou Date: Thu, 28 Apr 2022 13:14:00 +0200 Subject: [PATCH 1/2] support for in/out parameters in call --- src/network/engine.hpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 25aef97e..350fbcbd 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -138,9 +138,9 @@ public: endpoint& operator=(endpoint&& /*rhs*/) = default; - template + void - call(const std::string& id, Args&&... args) { + call(const std::string& id, void* input = nullptr, void* output = nullptr) { const auto it = m_margo_context->m_rpc_names.find(id); @@ -159,7 +159,7 @@ public: ::HG_Error_to_string(ret))); } - ret = ::margo_forward(handle, nullptr); + ret = ::margo_forward(handle, input); if(ret != HG_SUCCESS) { throw std::runtime_error( @@ -167,6 +167,11 @@ public: ::HG_Error_to_string(ret))); } + if (output != nullptr) { + ret = ::margo_get_output(handle, output); + } + + ret = ::margo_destroy(handle); if(ret != HG_SUCCESS) { -- GitLab From 7afd6b16e2f6ae33eea9864ac2a71081ec3ccf2b Mon Sep 17 00:00:00 2001 From: Ramon Nou Date: Wed, 4 May 2022 10:03:19 +0000 Subject: [PATCH 2/2] Deprecated call and restore of generic function --- src/network/engine.hpp | 44 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 350fbcbd..1321ae38 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -138,7 +138,49 @@ public: endpoint& operator=(endpoint&& /*rhs*/) = default; - + template + void + call(const std::string& id, Args&&... args) { + + const auto it = m_margo_context->m_rpc_names.find(id); + + if(it == m_margo_context->m_rpc_names.end()) { + throw std::runtime_error( + fmt::format("Unknown remote procedure: {}", id)); + } + + hg_handle_t handle; + auto ret = ::margo_create(m_margo_context->m_mid, + m_address->mercury_address(), it->second, + &handle); + if(ret != HG_SUCCESS) { + throw std::runtime_error( + fmt::format("Error during endpoint::call(): {}", + ::HG_Error_to_string(ret))); + } + + ret = ::margo_forward(handle, nullptr); + + if(ret != HG_SUCCESS) { + throw std::runtime_error( + fmt::format("Error during endpoint::call(): {}", + ::HG_Error_to_string(ret))); + } + + ret = ::margo_destroy(handle); + + if(ret != HG_SUCCESS) { + throw std::runtime_error( + fmt::format("Error during endpoint::call(): {}", + ::HG_Error_to_string(ret))); + } + } + + /** + * Deprecated call, used to support Margo directly + * + **/ + [[deprecated("It should be eventually replaced by a generic call")]] void call(const std::string& id, void* input = nullptr, void* output = nullptr) { -- GitLab