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 noexcept final;
50  bool wantsInputProcessBlocks() const noexcept final;
51  bool wantsGlobalRuns() const noexcept final;
52  bool wantsGlobalLuminosityBlocks() const noexcept final;
53  bool wantsStreamRuns() const noexcept final;
54  bool wantsStreamLuminosityBlocks() const noexcept 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 noexcept final;
92 
94 
95  size_t transformIndex(edm::BranchDescription const&) const noexcept final;
97  size_t iTransformIndex,
100  ServiceWeakToken const&) noexcept final;
101  ProductResolverIndex itemToGetForTransform(size_t iTransformIndex) const noexcept 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 noexcept override {
163  module_->preActionBeforeRunEventAsync(iTask, iModuleCallingContext, iPrincipal);
164  }
165 
166  bool hasAcquire() const noexcept override { return module_->hasAcquire(); }
167 
168  bool hasAccumulator() const noexcept 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:739
void itemsToGet(BranchType branchType, std::vector< ProductResolverIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:141
void resetModuleDescription(ModuleDescription const *)
Definition: Worker.cc:281
bool wantsGlobalLuminosityBlocks() const noexcept final
Definition: WorkerT.cc:141
std::vector< ESResolverIndex > const & esItemsToGetFrom(Transition iTransition) const override
Definition: WorkerT.h:153
bool implDoEndProcessBlock(ProcessBlockPrincipal const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:457
SerialTaskQueue * globalRunsQueue() final
Definition: WorkerT.cc:156
roAction_t actions[nactions]
Definition: GenABIO.cc:181
void implDoTransformAsync(WaitingTaskHolder, size_t iTransformIndex, EventPrincipal const &, ParentContext const &, ServiceWeakToken const &) noexcept final
Definition: WorkerT.cc:246
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:574
std::string workerType() const override
Definition: WorkerT.cc:564
std::vector< ConsumesInfo > consumesInfo() const override
Definition: WorkerT.h:139
void callWorkerStreamEnd(D, StreamID, RunTransitionInfo const &, ModuleCallingContext const *)
Definition: WorkerT.cc:479
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 implDoStreamEnd(StreamID, RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:496
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:387
ProductResolverIndex itemToGetForTransform(size_t iTransformIndex) const noexcept final
Definition: WorkerT.cc:343
bool implDoAccessInputProcessBlock(ProcessBlockPrincipal const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:451
BranchType
Definition: BranchType.h:11
void callWorkerStreamBegin(D, StreamID, RunTransitionInfo const &, ModuleCallingContext const *)
Definition: WorkerT.cc:470
edm::propagate_const< std::shared_ptr< T > > module_
Definition: WorkerT.h:170
void itemsToGetForSelection(std::vector< ProductResolverIndexAndSkipBit > &) const final
Definition: WorkerT.cc:393
void implRespondToOpenInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:611
void implRespondToCloseOutputFile() override
Definition: WorkerT.cc:621
void preActionBeforeRunEventAsync(WaitingTaskHolder iTask, ModuleCallingContext const &iModuleCallingContext, Principal const &iPrincipal) const noexcept override
Definition: WorkerT.h:160
Types moduleType() const override
void callWorkerEndStream(D, StreamID)
Definition: WorkerT.cc:596
bool wantsGlobalRuns() const noexcept final
Definition: WorkerT.cc:136
bool hasAcquire() const noexcept override
Definition: WorkerT.h:166
void implBeginStream(StreamID) override
Definition: WorkerT.cc:585
void resolvePutIndicies(BranchType iBranchType, std::unordered_multimap< std::string, std::tuple< TypeID const *, const char *, edm::ProductResolverIndex >> const &iIndicies) final
Definition: WorkerT.cc:787
bool implDoStreamBegin(StreamID, RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:484
Transition
Definition: Transition.h:12
bool implNeedToRunSelection() const noexcept final
Definition: WorkerT.cc:382
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
Definition: Types.py:1
bool wantsStreamRuns() const noexcept final
Definition: WorkerT.cc:146
TaskQueueAdaptor serializeRunModule() override
Definition: WorkerT.cc:632
ConcurrencyTypes
Definition: Worker.h:95
~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:445
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:141
void implEndStream(StreamID) override
Definition: WorkerT.cc:601
void implBeginJob() override
Definition: WorkerT.cc:569
void implRespondToCloseInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:616
bool implDoEnd(RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:506
void callWorkerBeginStream(D, StreamID)
Definition: WorkerT.cc:580
bool wantsProcessBlocks() const noexcept final
Definition: WorkerT.cc:126
size_t transformIndex(edm::BranchDescription const &) const noexcept final
Definition: WorkerT.cc:309
void implDoAcquire(EventTransitionInfo const &, ModuleCallingContext const *, WaitingTaskWithArenaHolder &) final
Definition: WorkerT.cc:206
void doClearModule() override
Definition: WorkerT.h:86
HLT enums.
void itemsMayGet(BranchType branchType, std::vector< ProductResolverIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:145
void implRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &) override
Definition: WorkerT.cc:626
bool hasAccumulator() const noexcept override
Definition: WorkerT.h:168
bool implDoBegin(RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:463
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
bool wantsInputProcessBlocks() const noexcept final
Definition: WorkerT.cc:131
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:749
bool wantsStreamLuminosityBlocks() const noexcept final
Definition: WorkerT.cc:151
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