|
1 | | -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. |
| 1 | +// Copyright 2019-2026 CERN and copyright holders of ALICE O2. |
2 | 2 | // See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. |
3 | 3 | // All rights not expressly granted are reserved. |
4 | 4 | // |
|
11 | 11 |
|
12 | 12 | #include "Framework/CompletionPolicyHelpers.h" |
13 | 13 | #include "Framework/CompletionPolicy.h" |
| 14 | +#include "Framework/DataProcessingHeader.h" |
14 | 15 | #include "Framework/InputSpan.h" |
15 | 16 | #include "Framework/DeviceSpec.h" |
16 | 17 | #include "Framework/CompilerBuiltins.h" |
@@ -263,6 +264,32 @@ CompletionPolicy CompletionPolicyHelpers::consumeWhenAnyZeroCount(const char* na |
263 | 264 | return CompletionPolicy{name, matcher, callback, false}; |
264 | 265 | } |
265 | 266 |
|
| 267 | +CompletionPolicy CompletionPolicyHelpers::consumeWhenPastOldestPossibleTimeframe(const char* name, CompletionPolicy::Matcher matcher) |
| 268 | +{ |
| 269 | + auto callback = [](InputSpan const& inputs, std::vector<InputSpec> const&, ServiceRegistryRef& ref) -> CompletionPolicy::CompletionOp { |
| 270 | + size_t currentTimeslice = -1; |
| 271 | + for (auto& input : inputs) { |
| 272 | + if (input.header == nullptr) { |
| 273 | + continue; |
| 274 | + } |
| 275 | + o2::framework::DataProcessingHeader const* dph = o2::header::get<o2::framework::DataProcessingHeader*>(input.header); |
| 276 | + if (dph && !TimingInfo::timesliceIsTimer(dph->startTime)) { |
| 277 | + currentTimeslice = dph->startTime; |
| 278 | + break; |
| 279 | + } |
| 280 | + } |
| 281 | + |
| 282 | + auto& timesliceIndex = ref.get<TimesliceIndex>(); |
| 283 | + auto oldestPossibleTimeslice = timesliceIndex.getOldestPossibleInput().timeslice.value; |
| 284 | + |
| 285 | + if (currentTimeslice >= oldestPossibleTimeslice) { |
| 286 | + return CompletionPolicy::CompletionOp::Retry; |
| 287 | + } |
| 288 | + return CompletionPolicy::CompletionOp::Consume; |
| 289 | + }; |
| 290 | + return CompletionPolicy{name, matcher, callback, false}; |
| 291 | +} |
| 292 | + |
266 | 293 | CompletionPolicy CompletionPolicyHelpers::consumeWhenAny(const char* name, CompletionPolicy::Matcher matcher) |
267 | 294 | { |
268 | 295 | auto callback = [](InputSpan const& inputs, std::vector<InputSpec> const&, ServiceRegistryRef& ref) -> CompletionPolicy::CompletionOp { |
|
0 commit comments