Project
Loading...
Searching...
No Matches
test_SlowConsumer.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.
16#include <fairmq/Device.h>
17
18#include <chrono>
19#include <thread>
20#include <vector>
21
23using namespace o2::framework;
24
25// This is how you can define your processing in a declarative way
27{
28 return WorkflowSpec{
29 {"A",
30 Inputs{},
31 {OutputSpec{{"a"}, "TST", "A"}},
33 [](DataAllocator& outputs, RawDeviceService& device, ControlService& control) {
34 static int count = 0;
35 auto& aData = outputs.make<int>(OutputRef{"a"});
36 LOG(info) << count;
37 aData = count++;
38 if (count > 1000) {
39 control.endOfStream();
40 control.readyToQuit(QuitRequest::Me);
41 }
42 }); })}},
43 {"B",
44 {InputSpec{"x", "TST", "A", Lifetime::Timeframe}},
45 {},
47 [](InputRecord& inputs, RawDeviceService& device, ControlService& control) {
48 static int expected = 0;
49 device.device()->WaitFor(std::chrono::milliseconds(3));
50 auto& count = inputs.get<int>("x");
51 if (expected != count) {
52 LOGP(error, "Missing message. Expected: {}, Found {}.", expected, count);
53 control.readyToQuit(QuitRequest::All);
54 }
55 expected++;
56 }); })}}};
57}
void readyToQuit(bool all)
Compatibility with old API.
void endOfStream()
Signal that we are done with the current stream.
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
virtual fair::mq::Device * device()=0
GLint GLsizei count
Definition glcorearb.h:399
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< DataProcessorSpec > WorkflowSpec
AlgorithmSpec::ProcessCallback adaptStateless(LAMBDA l)
std::vector< InputSpec > Inputs
AlgorithmSpec::InitCallback adaptStateful(LAMBDA l)
std::map< std::string, ID > expected
WorkflowSpec defineDataProcessing(ConfigContext const &specs)
This function hooks up the the workflow specifications into the DPL driver.
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"