CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 <map>
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
23 namespace edm {
24 
25  class ModuleCallingContext;
26  class ModuleProcessName;
27  class ProductResolverIndexAndSkipBit;
28  class ThinnedAssociationsHelper;
29  class WaitingTaskWithArenaHolder;
30 
31  template <typename T>
32  class WorkerT : public Worker {
33  public:
34  typedef T ModuleType;
36  WorkerT(std::shared_ptr<T>, ModuleDescription const&, ExceptionToActionTable const* actions);
37 
38  ~WorkerT() override;
39 
40  void setModule(std::shared_ptr<T> iModule) {
41  module_ = iModule;
42  resetModuleDescription(&(module_->moduleDescription()));
43  }
44 
45  Types moduleType() const override;
46  ConcurrencyTypes moduleConcurrencyType() const override;
47 
48  bool wantsProcessBlocks() const final;
49  bool wantsInputProcessBlocks() const final;
50  bool wantsGlobalRuns() const final;
52  bool wantsStreamRuns() const final;
54 
57 
58  void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const&) final;
59  void updateLookup(eventsetup::ESRecordsToProxyIndices const&) final;
61 
62  void resolvePutIndicies(
63  BranchType iBranchType,
64  std::unordered_multimap<std::string, std::tuple<TypeID const*, const char*, edm::ProductResolverIndex>> const&
65  iIndicies) final;
66 
67  template <typename D>
69  template <typename D>
70  void callWorkerEndStream(D, StreamID);
71  template <typename D>
72  void callWorkerStreamBegin(D, StreamID, RunTransitionInfo const&, ModuleCallingContext const*);
73  template <typename D>
74  void callWorkerStreamEnd(D, StreamID, RunTransitionInfo const&, ModuleCallingContext const*);
75  template <typename D>
76  void callWorkerStreamBegin(D, StreamID, LumiTransitionInfo const&, ModuleCallingContext const*);
77  template <typename D>
78  void callWorkerStreamEnd(D, StreamID, LumiTransitionInfo const&, ModuleCallingContext const*);
79 
80  protected:
81  T& module() { return *module_; }
82  T const& module() const { return *module_; }
83 
84  private:
85  void doClearModule() override { get_underlying_safe(module_).reset(); }
86 
87  bool implDo(EventTransitionInfo const&, ModuleCallingContext const*) override;
88 
89  void itemsToGetForSelection(std::vector<ProductResolverIndexAndSkipBit>&) const final;
90  bool implNeedToRunSelection() const final;
91 
93 
98  bool implDoBegin(RunTransitionInfo const&, ModuleCallingContext const*) override;
99  bool implDoStreamBegin(StreamID, RunTransitionInfo const&, ModuleCallingContext const*) override;
100  bool implDoStreamEnd(StreamID, RunTransitionInfo const&, ModuleCallingContext const*) override;
101  bool implDoEnd(RunTransitionInfo const&, ModuleCallingContext const*) override;
102  bool implDoBegin(LumiTransitionInfo const&, ModuleCallingContext const*) override;
103  bool implDoStreamBegin(StreamID, LumiTransitionInfo const&, ModuleCallingContext const*) override;
104  bool implDoStreamEnd(StreamID, LumiTransitionInfo const&, ModuleCallingContext const*) override;
105  bool implDoEnd(LumiTransitionInfo const&, ModuleCallingContext const*) override;
106  void implBeginJob() override;
107  void implEndJob() override;
108  void implBeginStream(StreamID) override;
109  void implEndStream(StreamID) override;
110  void implRespondToOpenInputFile(FileBlock const& fb) override;
111  void implRespondToCloseInputFile(FileBlock const& fb) override;
112  void implRespondToCloseOutputFile() override;
114  std::string workerType() const override;
115  TaskQueueAdaptor serializeRunModule() override;
116 
118  std::array<std::vector<ModuleDescription const*>*, NumBranchTypes>& modules,
119  std::vector<ModuleProcessName>& modulesInPreviousProcesses,
120  ProductRegistry const& preg,
121  std::map<std::string, ModuleDescription const*> const& labelsToDesc) const override {
122  module_->modulesWhoseProductsAreConsumed(
123  modules, modulesInPreviousProcesses, preg, labelsToDesc, module_->moduleDescription().processName());
124  }
125 
127  module_->convertCurrentProcessAlias(processName);
128  }
129 
130  std::vector<ConsumesInfo> consumesInfo() const override { return module_->consumesInfo(); }
131 
132  void itemsToGet(BranchType branchType, std::vector<ProductResolverIndexAndSkipBit>& indexes) const override {
133  module_->itemsToGet(branchType, indexes);
134  }
135 
136  void itemsMayGet(BranchType branchType, std::vector<ProductResolverIndexAndSkipBit>& indexes) const override {
137  module_->itemsMayGet(branchType, indexes);
138  }
139 
140  std::vector<ProductResolverIndexAndSkipBit> const& itemsToGetFrom(BranchType iType) const final {
141  return module_->itemsToGetFrom(iType);
142  }
143 
144  std::vector<ESProxyIndex> const& esItemsToGetFrom(Transition iTransition) const override {
145  return module_->esGetTokenIndicesVector(iTransition);
146  }
147  std::vector<ESRecordIndex> const& esRecordsToGetFrom(Transition iTransition) const override {
148  return module_->esGetTokenRecordIndicesVector(iTransition);
149  }
150 
151  std::vector<ProductResolverIndex> const& itemsShouldPutInEvent() const override;
152 
154  ModuleCallingContext const& iModuleCallingContext,
155  Principal const& iPrincipal) const override {
156  module_->preActionBeforeRunEventAsync(iTask, iModuleCallingContext, iPrincipal);
157  }
158 
159  bool hasAcquire() const override { return module_->hasAcquire(); }
160 
161  bool hasAccumulator() const override { return module_->hasAccumulator(); }
162 
164  };
165 
166 } // namespace edm
167 
168 #endif
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &) final
Definition: WorkerT.cc:654
void itemsToGet(BranchType branchType, std::vector< ProductResolverIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:132
tuple array
Definition: mps_check.py:216
void resetModuleDescription(ModuleDescription const *)
Definition: Worker.cc:287
bool hasAcquire() const override
Definition: WorkerT.h:159
bool hasAccumulator() const override
Definition: WorkerT.h:161
bool implDoEndProcessBlock(ProcessBlockPrincipal const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:347
SerialTaskQueue * globalRunsQueue() final
Definition: WorkerT.cc:159
unsigned int ProductResolverIndex
SerialTaskQueue * globalLuminosityBlocksQueue() final
Definition: WorkerT.cc:163
void convertCurrentProcessAlias(std::string const &processName) override
Definition: WorkerT.h:126
void implEndJob() override
Definition: WorkerT.cc:464
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:117
std::string workerType() const override
Definition: WorkerT.cc:454
std::vector< ConsumesInfo > consumesInfo() const override
Definition: WorkerT.h:130
void callWorkerStreamEnd(D, StreamID, RunTransitionInfo const &, ModuleCallingContext const *)
Definition: WorkerT.cc:369
bool wantsStreamLuminosityBlocks() const final
Definition: WorkerT.cc:154
T & module()
Definition: WorkerT.h:81
void setModule(std::shared_ptr< T > iModule)
Definition: WorkerT.h:40
std::vector< ESRecordIndex > const & esRecordsToGetFrom(Transition iTransition) const override
Definition: WorkerT.h:147
T const & module() const
Definition: WorkerT.h:82
bool implNeedToRunSelection() const final
Definition: WorkerT.cc:272
bool implDoStreamEnd(StreamID, RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:386
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:277
actions
Definition: Schedule.cc:687
bool implDoAccessInputProcessBlock(ProcessBlockPrincipal const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:341
BranchType
Definition: BranchType.h:11
void callWorkerStreamBegin(D, StreamID, RunTransitionInfo const &, ModuleCallingContext const *)
Definition: WorkerT.cc:360
edm::propagate_const< std::shared_ptr< T > > module_
Definition: WorkerT.h:163
void itemsToGetForSelection(std::vector< ProductResolverIndexAndSkipBit > &) const final
Definition: WorkerT.cc:283
void implRespondToOpenInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:501
void implRespondToCloseOutputFile() override
Definition: WorkerT.cc:511
std::vector< ESProxyIndex > const & esItemsToGetFrom(Transition iTransition) const override
Definition: WorkerT.h:144
Types moduleType() const override
void callWorkerEndStream(D, StreamID)
Definition: WorkerT.cc:486
void implBeginStream(StreamID) override
Definition: WorkerT.cc:475
void resolvePutIndicies(BranchType iBranchType, std::unordered_multimap< std::string, std::tuple< TypeID const *, const char *, edm::ProductResolverIndex >> const &iIndicies) final
Definition: WorkerT.cc:718
bool implDoStreamBegin(StreamID, RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:374
Transition
Definition: Transition.h:12
bool wantsInputProcessBlocks() const final
Definition: WorkerT.cc:134
TaskQueueAdaptor serializeRunModule() override
Definition: WorkerT.cc:522
bool wantsGlobalLuminosityBlocks() const final
Definition: WorkerT.cc:144
ConcurrencyTypes
Definition: Worker.h:95
~WorkerT() override
Definition: WorkerT.cc:126
T ModuleType
Definition: WorkerT.h:34
WorkerT< T > WorkerType
Definition: WorkerT.h:35
bool implDoBeginProcessBlock(ProcessBlockPrincipal const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:335
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:141
void implEndStream(StreamID) override
Definition: WorkerT.cc:491
void implBeginJob() override
Definition: WorkerT.cc:459
bool wantsProcessBlocks() const final
Definition: WorkerT.cc:129
void implRespondToCloseInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:506
bool implDoEnd(RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:396
void callWorkerBeginStream(D, StreamID)
Definition: WorkerT.cc:470
void implDoAcquire(EventTransitionInfo const &, ModuleCallingContext const *, WaitingTaskWithArenaHolder &) final
Definition: WorkerT.cc:232
void doClearModule() override
Definition: WorkerT.h:85
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:136
void preActionBeforeRunEventAsync(WaitingTaskHolder iTask, ModuleCallingContext const &iModuleCallingContext, Principal const &iPrincipal) const override
Definition: WorkerT.h:153
void implRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &) override
Definition: WorkerT.cc:516
std::vector< ProductResolverIndex > const & itemsShouldPutInEvent() const override
Definition: WorkerT.cc:726
bool implDoBegin(RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:353
preg
Definition: Schedule.cc:687
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:664
ConcurrencyTypes moduleConcurrencyType() const override
def template
Definition: svgfig.py:521
bool implDo(EventTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:225
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom(BranchType iType) const final
Definition: WorkerT.h:140