From 6102a523ea7665f5155e683dba520e8e1f6ae622 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Tue, 14 Nov 2023 15:00:39 +0100 Subject: [PATCH] DPL: reset the async queue on STOP --- Framework/Core/include/Framework/AsyncQueue.h | 3 +++ Framework/Core/src/AsyncQueue.cxx | 6 ++++++ Framework/Core/src/CommonServices.cxx | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/Framework/Core/include/Framework/AsyncQueue.h b/Framework/Core/include/Framework/AsyncQueue.h index 543dfd6994152..37971fbe03bfb 100644 --- a/Framework/Core/include/Framework/AsyncQueue.h +++ b/Framework/Core/include/Framework/AsyncQueue.h @@ -59,6 +59,9 @@ struct AsyncQueueHelpers { /// 2. then priority /// 3. only execute the highest (timeslice, debounce) value static void run(AsyncQueue& queue, TimesliceId oldestPossibleTimeslice); + + /// Reset the queue to its initial state + static void reset(AsyncQueue& queue); }; } // namespace o2::framework diff --git a/Framework/Core/src/AsyncQueue.cxx b/Framework/Core/src/AsyncQueue.cxx index 36d72bf1b3dd7..44115d4985e91 100644 --- a/Framework/Core/src/AsyncQueue.cxx +++ b/Framework/Core/src/AsyncQueue.cxx @@ -107,4 +107,10 @@ auto AsyncQueueHelpers::run(AsyncQueue& queue, TimesliceId oldestPossible) -> vo queue.tasks.end()); } +auto AsyncQueueHelpers::reset(AsyncQueue& queue) -> void +{ + queue.tasks.clear(); + queue.iteration = 0; +} + } // namespace o2::framework diff --git a/Framework/Core/src/CommonServices.cxx b/Framework/Core/src/CommonServices.cxx index 4caddb9b98c78..66e0330841ea6 100644 --- a/Framework/Core/src/CommonServices.cxx +++ b/Framework/Core/src/CommonServices.cxx @@ -135,6 +135,10 @@ o2::framework::ServiceSpec CommonServices::asyncQueue() .name = "async-queue", .init = simpleServiceInit(), .configure = noConfiguration(), + .stop = [](ServiceRegistryRef services, void* service) { + auto& queue = services.get(); + AsyncQueueHelpers::reset(queue); + }, .kind = ServiceKind::Serial}; }