From d6525231d16e442d5a4db7ac32cf950074d7d769 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 30 May 2017 23:22:18 -0700 Subject: rpc: Explicit code for non-returning RPC calls --- host/lib/utils/rpc.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'host') diff --git a/host/lib/utils/rpc.hpp b/host/lib/utils/rpc.hpp index dc6762928..f8cec8f26 100644 --- a/host/lib/utils/rpc.hpp +++ b/host/lib/utils/rpc.hpp @@ -73,6 +73,25 @@ class rpc_client } }; + template + void call(std::string const& func_name, Args&&... args) + { + std::lock_guard lock(_mutex); + try { + _client.call(func_name, std::forward(args)...); + } catch (const ::rpc::rpc_error &ex) { + throw uhd::runtime_error(str( + boost::format("Error during RPC call to `%s'. Error message: %s") + % func_name % ex.what() + )); + } catch (const std::bad_cast& ex) { + throw uhd::runtime_error(str( + boost::format("Error during RPC call to `%s'. Error message: %s") + % func_name % ex.what() + )); + } + }; + /*! Perform an RPC call; also includes a token. * * The first argument to the actual RPC function call is the current token -- cgit v1.2.3