Multithreading: Issue with empty message filter result
In current master
, empty input on filtered messages are allowed since it is implemented via the module's own receive
function (see e.g. https://gitlab.cern.ch/allpix-squared/allpix-squared/-/blob/master/src/modules/TextWriter/TextWriterModule.cpp#L63).
This has been renovated to a nicer infrastructure where no internal buffering of messages is necessary. The module simply decides with a filter
function which messages to keep, and fetchFilteredMessages
provides these in the run()
function of the module.
The issue now seems to be that an empty set of filtered messages is not allowed, throwing the exception:
|15:50:49.070| (FATAL) (Event 1) [R:TextWriter] Error during execution of run:
Module TextWriter did not receive message BaseMessage
Please check your configuration and modules. Cannot continue.
Whenever no entry can be found when fetching messages for a module, a MessageNotFoundException
is thrown. However, in my opinion when asking for messages via a filter function, the return instead should be an empty vector.
@kwolters opinion?
That would mean:
diff --git a/src/core/messenger/Messenger.cpp b/src/core/messenger/Messenger.cpp
index f04fe40a2..ad35d7909 100644
--- a/src/core/messenger/Messenger.cpp
+++ b/src/core/messenger/Messenger.cpp
@@ -129,7 +129,7 @@ std::vector<std::pair<std::shared_ptr<BaseMessage>, std::string>> Messenger::fet
auto* local_messenger = event->get_local_messenger();
return local_messenger->fetchFilteredMessages(module);
} catch(const std::out_of_range& e) {
- throw MessageNotFoundException(module->getUniqueName(), typeid(BaseMessage));
+ return {};
}
}
anything speaks against that?