CMS 3D CMS Logo

WorkerT.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_WorkerT_h
2 #define FWCore_Framework_WorkerT_h
3 
4 /*----------------------------------------------------------------------
5 
6 WorkerT: Code common to all workers.
7 
8 ----------------------------------------------------------------------*/
9 
17 
18 #include <array>
19 #include <map>
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 namespace edm {
25 
26  class ModuleCallingContext;
27  class ModuleProcessName;
28  class ProductResolverIndexAndSkipBit;
29  class ThinnedAssociationsHelper;
30  class WaitingTaskWithArenaHolder;
31 
32  template <typename T>
33  class WorkerT : public Worker {
34  public:
35  typedef T ModuleType;
37  WorkerT(std::shared_ptr<T>, ModuleDescription const&, ExceptionToActionTable const* actions);
38 
39  ~WorkerT() override;
40 
41  void setModule(std::shared_ptr<T> iModule) {
42  module_ = iModule;
43  resetModuleDescription(&(module_->moduleDescription()));
44  }
45 
46  Types moduleType() const override;
47  ConcurrencyTypes moduleConcurrencyType() const override;
48 
49  bool wantsProcessBlocks() const final;
50  bool wantsInputProcessBlocks() const final;
51  bool wantsGlobalRuns() const final;
53  bool wantsStreamRuns() const final;
55 
58 
59  void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const&) final;
60  void updateLookup(eventsetup::ESRecordsToProductResolverIndices const&) final;
62 
63  void resolvePutIndicies(
64  BranchType iBranchType,
65  std::unordered_multimap<std::string, std::tuple<TypeID const*, const char*, edm::ProductResolverIndex>> const&
66  iIndicies) final;
67 
68  template <typename D>
70  template <typename D>
72  template <typename D>
74  template <typename D>
76  template <typename D>
78  template <typename D>
80 
81  protected:
82  T& module() { return *module_; }
83  T const& module() const { return *module_; }
84 
85  private:
86  void doClearModule() override { get_underlying_safe(module_).reset(); }
87 
88  bool implDo(EventTransitionInfo const&, ModuleCallingContext const*) override;
89 
90  void itemsToGetForSelection(std::vector<ProductResolverIndexAndSkipBit>&) const final;
91  bool implNeedToRunSelection() const final;
92 
94 
97  size_t iTransformIndex,
100  ServiceWeakToken const&) final;
101  ProductResolverIndex itemToGetForTransform(size_t iTransformIndex) const final;
102 
115  void implBeginJob() override;
116  void implEndJob() override;
117  void implBeginStream(StreamID) override;
118  void implEndStream(StreamID) override;
119  void implRespondToOpenInputFile(FileBlock const& fb) override;
120  void implRespondToCloseInputFile(FileBlock const& fb) override;
121  void implRespondToCloseOutputFile() override;
123  std::string workerType() const override;
124  TaskQueueAdaptor serializeRunModule() override;
125 
128  std::vector<ModuleProcessName>& modulesInPreviousProcesses,
129  ProductRegistry const& preg,
130  std::map<std::string, ModuleDescription const*> const& labelsToDesc) const override {
131  module_->modulesWhoseProductsAreConsumed(
132  modules, modulesInPreviousProcesses, preg, labelsToDesc, module_->moduleDescription().processName());
133  }
134 
136  module_->convertCurrentProcessAlias(processName);
137  }
138 
139  std::vector<ConsumesInfo> consumesInfo() const override { return module_->consumesInfo(); }
140 
141  void itemsToGet(BranchType branchType, std::vector<ProductResolverIndexAndSkipBit>& indexes) const override {
142  module_->itemsToGet(branchType, indexes);
143  }
144 
145  void itemsMayGet(BranchType branchType, std::vector<ProductResolverIndexAndSkipBit>& indexes) const override {
146  module_->itemsMayGet(branchType, indexes);
147  }
148 
149  std::vector<ProductResolverIndexAndSkipBit> const& itemsToGetFrom(BranchType iType) const final {
150  return module_->itemsToGetFrom(iType);
151  }
152 
153  std::vector<ESResolverIndex> const& esItemsToGetFrom(Transition iTransition) const override {
154  return module_->esGetTokenIndicesVector(iTransition);
155  }
156  std::vector<ESRecordIndex> const& esRecordsToGetFrom(Transition iTransition) const override {
157  return module_->esGetTokenRecordIndicesVector(iTransition);
158  }
159 
161  ModuleCallingContext const& iModuleCallingContext,
162  Principal const& iPrincipal) const override {
163  module_->preActionBeforeRunEventAsync(iTask, iModuleCallingContext, iPrincipal);
164  }
165 
166  bool hasAcquire() const override { return module_->hasAcquire(); }
167 
168  bool hasAccumulator() const override { return module_->hasAccumulator(); }
169 
171  };
172 
173 } // namespace edm
174 
175 #endif
T const & module() const
Definition: WorkerT.h:83
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &) final
Definition: WorkerT.cc:732
void itemsToGet(BranchType branchType, std::vector< ProductResolverIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:141
void resetModuleDescription(ModuleDescription const *)
Definition: Worker.cc:272
bool hasAcquire() const override
Definition: WorkerT.h:166
std::vector< ESResolverIndex > const & esItemsToGetFrom(Transition iTransition) const override
Definition: WorkerT.h:153
bool hasAccumulator() const override
Definition: WorkerT.h:168
bool implDoEndProcessBlock(ProcessBlockPrincipal const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:450
SerialTaskQueue * globalRunsQueue() final
Definition: WorkerT.cc:156
roAction_t actions[nactions]
Definition: GenABIO.cc:181
unsigned int ProductResolverIndex
SerialTaskQueue * globalLuminosityBlocksQueue() final
Definition: WorkerT.cc:160
void convertCurrentProcessAlias(std::string const &processName) override
Definition: WorkerT.h:135
void implEndJob() override
Definition: WorkerT.cc:567
std::string workerType() const override
Definition: WorkerT.cc:557
std::vector< ConsumesInfo > consumesInfo() const override
Definition: WorkerT.h:139
void callWorkerStreamEnd(D, StreamID, RunTransitionInfo const &, ModuleCallingContext const *)
Definition: WorkerT.cc:472
bool wantsStreamLuminosityBlocks() const final
Definition: WorkerT.cc:151
void setModule(std::shared_ptr< T > iModule)
Definition: WorkerT.h:41
std::vector< ESRecordIndex > const & esRecordsToGetFrom(Transition iTransition) const override
Definition: WorkerT.h:156
bool implNeedToRunSelection() const final
Definition: WorkerT.cc:375
bool implDoStreamEnd(StreamID, RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:489
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
bool implDoPrePrefetchSelection(StreamID, EventPrincipal const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:380
bool implDoAccessInputProcessBlock(ProcessBlockPrincipal const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:444
BranchType
Definition: BranchType.h:11
void callWorkerStreamBegin(D, StreamID, RunTransitionInfo const &, ModuleCallingContext const *)
Definition: WorkerT.cc:463
edm::propagate_const< std::shared_ptr< T > > module_
Definition: WorkerT.h:170
void itemsToGetForSelection(std::vector< ProductResolverIndexAndSkipBit > &) const final
Definition: WorkerT.cc:386
size_t transformIndex(edm::BranchDescription const &) const final
Definition: WorkerT.cc:308
void implRespondToOpenInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:604
void implRespondToCloseOutputFile() override
Definition: WorkerT.cc:614
Types moduleType() const override
void callWorkerEndStream(D, StreamID)
Definition: WorkerT.cc:589
void implBeginStream(StreamID) override
Definition: WorkerT.cc:578
void resolvePutIndicies(BranchType iBranchType, std::unordered_multimap< std::string, std::tuple< TypeID const *, const char *, edm::ProductResolverIndex >> const &iIndicies) final
Definition: WorkerT.cc:780
bool implDoStreamBegin(StreamID, RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:477
Transition
Definition: Transition.h:12
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
bool wantsInputProcessBlocks() const final
Definition: WorkerT.cc:131
Definition: Types.py:1
TaskQueueAdaptor serializeRunModule() override
Definition: WorkerT.cc:625
bool wantsGlobalLuminosityBlocks() const final
Definition: WorkerT.cc:141
ConcurrencyTypes
Definition: Worker.h:96
~WorkerT() override
Definition: WorkerT.cc:123
T ModuleType
Definition: WorkerT.h:35
WorkerT< T > WorkerType
Definition: WorkerT.h:36
bool implDoBeginProcessBlock(ProcessBlockPrincipal const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:438
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:141
void implEndStream(StreamID) override
Definition: WorkerT.cc:594
void implDoTransformAsync(WaitingTaskHolder, size_t iTransformIndex, EventPrincipal const &, ParentContext const &, ServiceWeakToken const &) final
Definition: WorkerT.cc:246
void implBeginJob() override
Definition: WorkerT.cc:562
bool wantsProcessBlocks() const final
Definition: WorkerT.cc:126
void implRespondToCloseInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:609
bool implDoEnd(RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:499
void callWorkerBeginStream(D, StreamID)
Definition: WorkerT.cc:573
void implDoAcquire(EventTransitionInfo const &, ModuleCallingContext const *, WaitingTaskWithArenaHolder &) final
Definition: WorkerT.cc:206
void doClearModule() override
Definition: WorkerT.h:86
HLT enums.
ProductResolverIndex itemToGetForTransform(size_t iTransformIndex) const final
Definition: WorkerT.cc:341
bool wantsGlobalRuns() const final
Definition: WorkerT.cc:136
bool wantsStreamRuns() const final
Definition: WorkerT.cc:146
void itemsMayGet(BranchType branchType, std::vector< ProductResolverIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:145
void preActionBeforeRunEventAsync(WaitingTaskHolder iTask, ModuleCallingContext const &iModuleCallingContext, Principal const &iPrincipal) const override
Definition: WorkerT.h:160
void implRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &) override
Definition: WorkerT.cc:619
bool implDoBegin(RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:456
void modulesWhoseProductsAreConsumed(std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modules, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc) const override
Definition: WorkerT.h:126
long double T
WorkerT(std::shared_ptr< T >, ModuleDescription const &, ExceptionToActionTable const *actions)
Definition: WorkerT.cc:117
void selectInputProcessBlocks(ProductRegistry const &, ProcessBlockHelperBase const &) final
Definition: WorkerT.cc:742
ConcurrencyTypes moduleConcurrencyType() const override
bool implDo(EventTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:199
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom(BranchType iType) const final
Definition: WorkerT.h:149