diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-05-30 23:22:18 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:03:58 -0800 |
commit | d6525231d16e442d5a4db7ac32cf950074d7d769 (patch) | |
tree | c91319f406316c275c60d99530617c6acaab86f9 /host/lib/utils/rpc.hpp | |
parent | a233877f6554fa4d19dfcc4105e904414ea2ad1c (diff) | |
download | uhd-d6525231d16e442d5a4db7ac32cf950074d7d769.tar.gz uhd-d6525231d16e442d5a4db7ac32cf950074d7d769.tar.bz2 uhd-d6525231d16e442d5a4db7ac32cf950074d7d769.zip |
rpc: Explicit code for non-returning RPC calls
Diffstat (limited to 'host/lib/utils/rpc.hpp')
-rw-r--r-- | host/lib/utils/rpc.hpp | 19 |
1 files changed, 19 insertions, 0 deletions
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 <typename... Args> + void call(std::string const& func_name, Args&&... args) + { + std::lock_guard<std::mutex> lock(_mutex); + try { + _client.call(func_name, std::forward<Args>(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 |