From 1fd11b6fa36f53aaabd60e52c18739253b595e5c Mon Sep 17 00:00:00 2001 From: Thomas Debrunner Date: Thu, 28 Mar 2024 16:02:35 +0100 Subject: [PATCH] Connection: pass message callbacks by reference --- include/mav/Connection.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/mav/Connection.h b/include/mav/Connection.h index 76125b4..0254c6c 100644 --- a/include/mav/Connection.h +++ b/include/mav/Connection.h @@ -193,7 +193,7 @@ namespace mav { } CallbackHandle addMessageCallback(const std::function &on_message, - const std::function on_error) { + const std::function &on_error) { std::scoped_lock lock(_message_callback_mtx); CallbackHandle handle = _next_handle; _message_callbacks[handle] = FunctionCallback{on_message, on_error}; @@ -215,7 +215,7 @@ namespace mav { }, on_error); } - CallbackHandle addMessageCallback(int message_id, std::function on_message, + CallbackHandle addMessageCallback(int message_id, const std::function &on_message, int source_id=mav::ANY_ID, int component_id=mav::ANY_ID) { return addMessageCallback([message_id, source_id, component_id](const Message &message) { return message.id() == message_id && @@ -224,7 +224,7 @@ namespace mav { }, on_message, std::function{}); } - CallbackHandle addMessageCallback(const std::string &message_name, std::function on_message, + CallbackHandle addMessageCallback(const std::string &message_name, const std::function &on_message, int source_id=mav::ANY_ID, int component_id=mav::ANY_ID) { return addMessageCallback(_message_set.idForMessage(message_name), on_message, source_id, component_id); }