@@ -41,18 +41,20 @@ void customize(std::vector<CompletionPolicy>& policies)
4141#include " QualityControl/runnerUtils.h"
4242#include < Framework/runDataProcessing.h>
4343#include < Framework/ControlService.h>
44+ #include < set>
45+ #include < vector>
4446
4547using namespace o2 ::quality_control::core;
4648using namespace o2 ::quality_control::checker;
4749
4850/* *
49- * Test descrition
51+ * Test description
5052 *
51- * Test complex configuratio with 3 tasks and 3 checks.
53+ * Test a complex configuration with 3 tasks and 3 checks.
5254 * Checks sources contain several tasks with different policies.
5355 *
5456 * The goal is to check whether all checks are triggered and generate Quality Objects.
55- * It is expected to terminate whenever all task publish for the first time.
57+ * It is expected to terminate as soon as all task publish for the first time.
5658 */
5759
5860class Receiver : public framework ::Task
@@ -67,31 +69,34 @@ class Receiver : public framework::Task
6769 }
6870 }
6971
70- Receiver (const Receiver& receiver) : mNames (receiver.mNames ) {}
71-
7272 // / Destructor
7373 ~Receiver () override {};
7474
7575 // / \brief Receiver process callback
7676 void run (framework::ProcessingContext& pctx) override
7777 {
78- for (auto & checkName : mNames ) {
78+ std::vector<std::string> namesToErase;
79+
80+ for (const auto & checkName : mNames ) {
7981 if (pctx.inputs ().isValid (checkName)) {
8082 auto qo = pctx.inputs ().get <QualityObject*>(checkName);
8183 if (!qo) {
8284 LOG (ERROR ) << qo->getName () << " - quality is NULL" ;
83- pctx.services ().get <ControlService>().readyToQuit (true );
85+ pctx.services ().get <ControlService>().readyToQuit (QuitRequest::All );
8486 } else {
85- LOG (DEBUG ) << qo->getName () << " - qualit: " << qo->getQuality ();
86-
87- mNames .erase (checkName);
87+ LOG (DEBUG ) << qo->getName () << " - quality: " << qo->getQuality ();
88+ namesToErase.emplace_back (checkName);
8889 }
89- // We ask to shut the topology down, returning 0 if there were no ERROR logs.
9090 }
9191 }
9292
93- if (!mNames .size ()) {
94- pctx.services ().get <ControlService>().readyToQuit (true );
93+ for (const auto & nameToErase : namesToErase) {
94+ mNames .erase (nameToErase);
95+ }
96+
97+ if (mNames .empty ()) {
98+ // We ask to shut the topology down, returning 0 if there were no ERROR logs.
99+ pctx.services ().get <ControlService>().readyToQuit (QuitRequest::All);
95100 }
96101 LOG (DEBUG ) << " Requires " << mNames .size () << " quality objects" ;
97102 }
@@ -139,15 +144,9 @@ WorkflowSpec defineDataProcessing(ConfigContext const&)
139144
140145 Receiver receiver (qcConfigurationSource);
141146 // Finally the receiver
142- DataProcessorSpec receiverSpec{
143- receiverName,
144- receiver.getInputs (),
145- Outputs{},
146- adaptFromTask<Receiver>(std::move (receiver)),
147- Options{},
148- std::vector<std::string>{},
149- std::vector<DataProcessorLabel>{}
150- };
147+ DataProcessorSpec receiverSpec{ receiverName, receiver.getInputs (), {}, {} };
148+ // We move the task at the end, so receiver.getInputs() is not called first.
149+ receiverSpec.algorithm = adaptFromTask<Receiver>(std::move (receiver));
151150 specs.push_back (receiverSpec);
152151
153152 return specs;
0 commit comments