Project
Loading...
Searching...
No Matches
test_WaitUntilPossible.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
20#include <fairmq/Device.h>
21
22#include <iostream>
23#include <chrono>
24#include <thread>
25#include <vector>
26
27using namespace o2::framework;
28
30
31// This is how you can define your processing in a declarative way
33{
35 .name = "A",
36 .outputs = {OutputSpec{{"data"}, "TST", "A1", 0}},
37 .algorithm = AlgorithmSpec{adaptStateless(
38 [](DataAllocator& outputs, RawDeviceService& device, DataTakingContext& context, ProcessingContext& pcx) {
39 LOG(info) << "Data TST/A1/0 created";
40 outputs.make<int>(OutputRef{"data"}, 1);
41 })},
42 };
44 .name = "B",
45 .outputs = {OutputSpec{{"sporadic"}, "TST", "B1", 0, Lifetime::Sporadic}},
46 .algorithm = AlgorithmSpec{adaptStateless(
47 [](DataAllocator& outputs, RawDeviceService& device, DataTakingContext& context, ProcessingContext& pcx) {
48 // This will always be late, however since the oldest possible timeframe
49 // will be used to decide the scheduling, it will not be dropped.
50 sleep(1);
51 // We also create it only every second time, so that we can check that
52 // the sporadic output is not mandatory.
53 static int i = 0;
54 if (i++ % 2 == 0) {
55 LOG(info) << "Data TST/B1/0 created";
56 outputs.make<int>(OutputRef{"sporadic"}, 1);
57 }
58 })},
59 };
61 .name = "D",
62 .inputs = {InputSpec{"a1", "TST", "A1", 0, Lifetime::Timeframe},
63 InputSpec{"b1", "TST", "B1", 0, Lifetime::Sporadic}},
64 .algorithm = AlgorithmSpec{adaptStateless(
65 [](InputRecord& inputs) {
66 auto refA = inputs.get("a1");
67 auto headerA = o2::header::get<const DataProcessingHeader*>(refA.header);
68 LOG(info) << "Start time: " << headerA->startTime;
69 auto refB = inputs.get("b1");
70 if (!refB.header) {
71 LOG(info) << "No sporadic input for start time " << headerA->startTime;
72 return;
73 }
74 auto headerB = o2::header::get<const DataProcessingHeader*>(refB.header);
75 LOG(info) << "Start time: " << headerB->startTime;
76 })},
77 };
78
81 WorkflowSpec{d});
82}
int32_t i
decltype(auto) make(const Output &spec, Args... args)
The input API of the Data Processing Layer This class holds the inputs which are valid for processing...
decltype(auto) get(R binding, int part=0) const
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
WorkflowSpec concat(T &&t, ARGS &&... args)
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< DataProcessorSpec > WorkflowSpec
AlgorithmSpec::ProcessCallback adaptStateless(LAMBDA l)
WorkflowSpec defineDataProcessing(ConfigContext const &specs)
This function hooks up the the workflow specifications into the DPL driver.
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"