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::ESRecordsToProxyIndices 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<ESProxyIndex> 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:801
void itemsToGet(BranchType branchType, std::vector< ProductResolverIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:141
void resetModuleDescription(ModuleDescription const *)
Definition: Worker.cc:265
bool hasAcquire() const override
Definition: WorkerT.h:166
bool hasAccumulator() const override
Definition: WorkerT.h:168
bool implDoEndProcessBlock(ProcessBlockPrincipal const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:494
SerialTaskQueue * globalRunsQueue() final
Definition: WorkerT.cc:159
roAction_t actions[nactions]
Definition: GenABIO.cc:181
unsigned int ProductResolverIndex
SerialTaskQueue * globalLuminosityBlocksQueue() final
Definition: WorkerT.cc:163
void convertCurrentProcessAlias(std::string const &processName) override
Definition: WorkerT.h:135
void implEndJob() override
Definition: WorkerT.cc:611
std::string workerType() const override
Definition: WorkerT.cc:601
std::vector< ConsumesInfo > consumesInfo() const override
Definition: WorkerT.h:139
void callWorkerStreamEnd(D, StreamID, RunTransitionInfo const &, ModuleCallingContext const *)
Definition: WorkerT.cc:516
bool wantsStreamLuminosityBlocks() const final
Definition: WorkerT.cc:154
T & module()
Definition: WorkerT.h:82
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:419
bool implDoStreamEnd(StreamID, RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:533
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:424
bool implDoAccessInputProcessBlock(ProcessBlockPrincipal const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:488
BranchType
Definition: BranchType.h:11
void callWorkerStreamBegin(D, StreamID, RunTransitionInfo const &, ModuleCallingContext const *)
Definition: WorkerT.cc:507
edm::propagate_const< std::shared_ptr< T > > module_
Definition: WorkerT.h:170
void itemsToGetForSelection(std::vector< ProductResolverIndexAndSkipBit > &) const final
Definition: WorkerT.cc:430
size_t transformIndex(edm::BranchDescription const &) const final
Definition: WorkerT.cc:352
void implRespondToOpenInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:648
void implRespondToCloseOutputFile() override
Definition: WorkerT.cc:658
std::vector< ESProxyIndex > const & esItemsToGetFrom(Transition iTransition) const override
Definition: WorkerT.h:153
Types moduleType() const override
void callWorkerEndStream(D, StreamID)
Definition: WorkerT.cc:633
void implBeginStream(StreamID) override
Definition: WorkerT.cc:622
void resolvePutIndicies(BranchType iBranchType, std::unordered_multimap< std::string, std::tuple< TypeID const *, const char *, edm::ProductResolverIndex >> const &iIndicies) final
Definition: WorkerT.cc:849
bool implDoStreamBegin(StreamID, RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:521
Transition
Definition: Transition.h:12
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
bool wantsInputProcessBlocks() const final
Definition: WorkerT.cc:134
Definition: Types.py:1
TaskQueueAdaptor serializeRunModule() override
Definition: WorkerT.cc:669
bool wantsGlobalLuminosityBlocks() const final
Definition: WorkerT.cc:144
ConcurrencyTypes
Definition: Worker.h:96
~WorkerT() override
Definition: WorkerT.cc:126
T ModuleType
Definition: WorkerT.h:35
WorkerT< T > WorkerType
Definition: WorkerT.h:36
bool implDoBeginProcessBlock(ProcessBlockPrincipal const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:482
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:141
void implEndStream(StreamID) override
Definition: WorkerT.cc:638
void implDoTransformAsync(WaitingTaskHolder, size_t iTransformIndex, EventPrincipal const &, ParentContext const &, ServiceWeakToken const &) final
Definition: WorkerT.cc:272
void implBeginJob() override
Definition: WorkerT.cc:606
bool wantsProcessBlocks() const final
Definition: WorkerT.cc:129
void implRespondToCloseInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:653
bool implDoEnd(RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:543
void callWorkerBeginStream(D, StreamID)
Definition: WorkerT.cc:617
void implDoAcquire(EventTransitionInfo const &, ModuleCallingContext const *, WaitingTaskWithArenaHolder &) final
Definition: WorkerT.cc:232
void doClearModule() override
Definition: WorkerT.h:86
HLT enums.
ProductResolverIndex itemToGetForTransform(size_t iTransformIndex) const final
Definition: WorkerT.cc:385
bool wantsGlobalRuns() const final
Definition: WorkerT.cc:139
bool wantsStreamRuns() const final
Definition: WorkerT.cc:149
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:663
bool implDoBegin(RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:500
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:120
void selectInputProcessBlocks(ProductRegistry const &, ProcessBlockHelperBase const &) final
Definition: WorkerT.cc:811
ConcurrencyTypes moduleConcurrencyType() const override
bool implDo(EventTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:225
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom(BranchType iType) const final
Definition: WorkerT.h:149