Skip to content

Commit

Permalink
DPL: reset the async queue on STOP
Browse files Browse the repository at this point in the history
  • Loading branch information
ktf committed Nov 14, 2023
1 parent f207642 commit 6102a52
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Framework/Core/include/Framework/AsyncQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions Framework/Core/src/AsyncQueue.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions Framework/Core/src/CommonServices.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ o2::framework::ServiceSpec CommonServices::asyncQueue()
.name = "async-queue",
.init = simpleServiceInit<AsyncQueue, AsyncQueue>(),
.configure = noConfiguration(),
.stop = [](ServiceRegistryRef services, void* service) {
auto& queue = services.get<AsyncQueue>();
AsyncQueueHelpers::reset(queue);
},
.kind = ServiceKind::Serial};
}

Expand Down

0 comments on commit 6102a52

Please sign in to comment.