|
| 1 | +// Copyright CERN and copyright holders of ALICE O2. This software is |
| 2 | +// distributed under the terms of the GNU General Public License v3 (GPL |
| 3 | +// Version 3), copied verbatim in the file "COPYING". |
| 4 | +// |
| 5 | +// See http://alice-o2.web.cern.ch/license for full licensing information. |
| 6 | +// |
| 7 | +// In applying this license CERN does not waive the privileges and immunities |
| 8 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 9 | +// or submit itself to any jurisdiction. |
| 10 | +#include "Framework/ConfigContext.h" |
| 11 | +#include "Framework/ControlService.h" |
| 12 | +#include "Framework/DataProcessorSpec.h" |
| 13 | +#include "Framework/DataSpecUtils.h" |
| 14 | +#include "Framework/Logger.h" |
| 15 | +#include "Framework/ParallelContext.h" |
| 16 | +#include "Framework/DataDescriptorQueryBuilder.h" |
| 17 | + |
| 18 | +#include <chrono> |
| 19 | +#include <thread> |
| 20 | +#include <vector> |
| 21 | + |
| 22 | +/// A DataProcessor which terminates a provided set of |
| 23 | +/// inputs. |
| 24 | +using namespace o2::framework; |
| 25 | + |
| 26 | +void customize(std::vector<ConfigParamSpec>& options) |
| 27 | +{ |
| 28 | + options.push_back(o2::framework::ConfigParamSpec{"inputs", VariantType::String, "", {"inputs for the dataprocessor"}}); |
| 29 | +}; |
| 30 | + |
| 31 | +#include "Framework/runDataProcessing.h" |
| 32 | + |
| 33 | +// This is a simple consumer / producer workflow where both are |
| 34 | +// stateful, i.e. they have context which comes from their initialization. |
| 35 | +WorkflowSpec defineDataProcessing(ConfigContext const& context) |
| 36 | +{ |
| 37 | + WorkflowSpec workflow; |
| 38 | + // This is an example of how we can parallelize by subSpec. |
| 39 | + // templatedProducer will be instanciated 32 times and the lambda function |
| 40 | + // passed to the parallel statement will be applied to each one of the |
| 41 | + // instances in order to modify it. Parallel will also make sure the name of |
| 42 | + // the instance is amended from "some-producer" to "some-producer-<index>". |
| 43 | + auto inputsDesc = context.options().get<std::string>("inputs"); |
| 44 | + auto inputs = DataDescriptorQueryBuilder::parse(inputsDesc.c_str()); |
| 45 | + |
| 46 | + workflow.push_back(DataProcessorSpec{ |
| 47 | + "null", |
| 48 | + inputs, |
| 49 | + {}, |
| 50 | + AlgorithmSpec{[](ProcessingContext& ctx) {}}}); |
| 51 | + |
| 52 | + return workflow; |
| 53 | +} |
0 commit comments