CMS 3D CMS Logo

WorkerT.cc
Go to the documentation of this file.
3 
16 
20 
21 #include <type_traits>
22 
23 namespace edm{
24  namespace workerimpl {
25  template<typename T>
27  static bool constexpr value = false;
28  };
29 
30  template<>
32  static bool constexpr value = true;
33  };
34 
35  template<>
37  static bool constexpr value = true;
38  };
39 
40  template<>
42  static bool constexpr value = true;
43  };
44 
45  template<>
47  static bool constexpr value = true;
48  };
49 
50  template<>
52  static bool constexpr value = true;
53  };
54 
55  template<>
57  static bool constexpr value = true;
58  };
59 
60  struct DoNothing {
61  template< typename... T>
62  inline void operator()(const T&...) {}
63  };
64 
65  template<typename T>
66  struct DoBeginStream {
67  inline void operator()(WorkerT<T>* iWorker, StreamID id) {
68  iWorker->callWorkerBeginStream(0,id);
69  }
70  };
71 
72  template<typename T>
73  struct DoEndStream {
74  inline void operator()(WorkerT<T>* iWorker, StreamID id) {
75  iWorker->callWorkerEndStream(0,id);
76  }
77  };
78 
79  template<typename T, typename P>
81  inline void operator() (WorkerT<T>* iWorker, StreamID id, P const& rp,
82  EventSetup const& c,
83  ModuleCallingContext const* mcc) {
84  iWorker->callWorkerStreamBegin(0,id,rp,c, mcc);
85  }
86  };
87 
88  template<typename T, typename P>
90  inline void operator() (WorkerT<T>* iWorker, StreamID id, P const& rp,
91  EventSetup const& c,
92  ModuleCallingContext const* mcc) {
93  iWorker->callWorkerStreamEnd(0,id,rp,c, mcc);
94  }
95  };
96  }
97 
98  template<typename T>
99  inline
100  WorkerT<T>::WorkerT(std::shared_ptr<T> ed, ModuleDescription const& md, ExceptionToActionTable const* actions) :
101  Worker(md, actions),
102  module_(ed) {
103  assert(module_ != 0);
104  }
105 
106  template<typename T>
108  }
109 
110  template<typename T>
111  inline
112  bool
114  std::shared_ptr<Worker> sentry(this,[&ep](Worker* obj) {obj->postDoEvent(ep);});
115  return module_->doEvent(ep, c, activityRegistry(), mcc);
116  }
117 
118  template<typename T>
119  inline
120  bool
122  EventPrincipal const& ep,
123  ModuleCallingContext const* mcc) {
124  return true;
125  }
126 
127  template<>
128  inline
129  bool
131  EventPrincipal const& ep,
132  ModuleCallingContext const* mcc) {
133  return module_->prePrefetchSelection(id,ep,mcc);
134  }
135 
136  template<>
137  inline
138  bool
140  EventPrincipal const& ep,
141  ModuleCallingContext const* mcc) {
142  return module_->prePrefetchSelection(id,ep,mcc);
143  }
144 
145  template<>
146  inline
147  bool
149  EventPrincipal const& ep,
150  ModuleCallingContext const* mcc) {
151  return module_->prePrefetchSelection(id,ep,mcc);
152  }
153 
154  template<typename T>
155  inline
156  bool
158  module_->doBeginRun(rp, c, mcc);
159  return true;
160  }
161 
162  template<typename T>
163  template<typename D>
164  void
166  EventSetup const& c,
167  ModuleCallingContext const* mcc) {
168  module_->doStreamBeginRun(id, rp, c, mcc);
169  }
170 
171  template<typename T>
172  template<typename D>
173  void
175  EventSetup const& c,
176  ModuleCallingContext const* mcc) {
177  module_->doStreamEndRun(id, rp, c, mcc);
178  }
179 
180 
181  template<typename T>
182  inline
183  bool
185  ModuleCallingContext const* mcc) {
188  workerimpl::DoNothing> might_call;
189  might_call(this,id,rp,c, mcc);
190  return true;
191  }
192 
193  template<typename T>
194  inline
195  bool
197  ModuleCallingContext const* mcc) {
200  workerimpl::DoNothing> might_call;
201  might_call(this,id,rp,c, mcc);
202  return true;
203  }
204 
205  template<typename T>
206  inline
207  bool
209  ModuleCallingContext const* mcc) {
210  module_->doEndRun(rp, c, mcc);
211  return true;
212  }
213 
214  template<typename T>
215  inline
216  bool
218  ModuleCallingContext const* mcc) {
219  module_->doBeginLuminosityBlock(lbp, c, mcc);
220  return true;
221  }
222 
223  template<typename T>
224  template<typename D>
225  void
227  EventSetup const& c,
228  ModuleCallingContext const* mcc) {
229  module_->doStreamBeginLuminosityBlock(id, rp, c, mcc);
230  }
231 
232  template<typename T>
233  template<typename D>
234  void
236  EventSetup const& c,
237  ModuleCallingContext const* mcc) {
238  module_->doStreamEndLuminosityBlock(id, rp, c, mcc);
239  }
240 
241 
242  template<typename T>
243  inline
244  bool
246  ModuleCallingContext const* mcc) {
249  workerimpl::DoNothing> might_call;
250  might_call(this,id,lbp,c, mcc);
251  return true;
252  }
253 
254  template<typename T>
255  inline
256  bool
258  ModuleCallingContext const* mcc) {
261  workerimpl::DoNothing> might_call;
262  might_call(this,id,lbp,c,mcc);
263 
264  return true;
265  }
266 
267  template<typename T>
268  inline
269  bool
271  ModuleCallingContext const* mcc) {
272  module_->doEndLuminosityBlock(lbp, c, mcc);
273  return true;
274  }
275 
276  template<typename T>
277  inline
280  return module_->workerType();
281  }
282 
283  template<typename T>
284  inline
285  void
287  module_->doBeginJob();
288  }
289 
290  template<typename T>
291  inline
292  void
294  module_->doEndJob();
295  }
296 
297  template<typename T>
298  template<typename D>
300  module_->doBeginStream(id);
301  }
302 
303  template<typename T>
304  inline
305  void
309  workerimpl::DoNothing> might_call;
310  might_call(this,id);
311  }
312 
313  template<typename T>
314  template<typename D>
316  module_->doEndStream(id);
317  }
318 
319  template<typename T>
320  inline
321  void
325  workerimpl::DoNothing> might_call;
326  might_call(this,id);
327  }
328 
329  template<typename T>
330  inline
331  void
333  module_->doRespondToOpenInputFile(fb);
334  }
335 
336  template<typename T>
337  inline
338  void
340  module_->doRespondToCloseInputFile(fb);
341  }
342 
343  template<typename T>
344  inline
345  void
347  module_->doPreForkReleaseResources();
348  }
349 
350  template<typename T>
351  inline
352  void
354  unsigned int iNumberOfChildren) {
355  module_->doPostForkReacquireResources(iChildIndex, iNumberOfChildren);
356  }
357 
358 
359  template<typename T>
360  inline
361  void
364  module_->doRegisterThinnedAssociations(registry, helper);
365  }
366 
367  template<typename T>
368  inline
370  return nullptr;
371  }
373  return &(module_->sharedResourcesAcquirer().serialQueueChain());
374  }
376  return &(module_->sharedResourcesAcquirer().serialQueueChain());
377  }
379  return &(module_->sharedResourcesAcquirer().serialQueueChain());
380  }
382  return &(module_->sharedResourcesAcquirer().serialQueueChain());
383  }
385  return &(module_->sharedResourcesAcquirer().serialQueueChain());
386  }
388  return &(module_->sharedResourcesAcquirer().serialQueueChain());
389  }
391  return &(module_->sharedResourcesAcquirer().serialQueueChain());
392  }
394  return &(module_->sharedResourcesAcquirer().serialQueueChain());
395  }
396 
397 
398  namespace {
399  template <typename T> bool mustPrefetchMayGet();
400 
401  template<> bool mustPrefetchMayGet<EDAnalyzer>() { return true;}
402  template<> bool mustPrefetchMayGet<EDProducer>() { return true;}
403  template<> bool mustPrefetchMayGet<EDFilter>() { return true;}
404  template<> bool mustPrefetchMayGet<OutputModule>() { return true;}
405 
406  template<> bool mustPrefetchMayGet<edm::one::EDProducerBase>() { return true;}
407  template<> bool mustPrefetchMayGet<edm::one::EDFilterBase>() { return true;}
408  template<> bool mustPrefetchMayGet<edm::one::EDAnalyzerBase>() { return true;}
409  template<> bool mustPrefetchMayGet<edm::one::OutputModuleBase>() { return true;}
410 
411  template<> bool mustPrefetchMayGet<edm::global::EDProducerBase>() { return true;}
412  template<> bool mustPrefetchMayGet<edm::global::EDFilterBase>() { return true;}
413  template<> bool mustPrefetchMayGet<edm::global::EDAnalyzerBase>() { return true;}
414  template<> bool mustPrefetchMayGet<edm::global::OutputModuleBase>() { return true;}
415 
416  template<> bool mustPrefetchMayGet<edm::stream::EDProducerAdaptorBase>() { return true;}
417  template<> bool mustPrefetchMayGet<edm::stream::EDFilterAdaptorBase>() { return true;}
418  template<> bool mustPrefetchMayGet<edm::stream::EDAnalyzerAdaptorBase>() { return true;}
419 
420  }
421 
422 
423  template<typename T>
425  ProductResolverIndexHelper const& iHelper) {
426  module_->updateLookup(iBranchType,iHelper,mustPrefetchMayGet<T>());
427  }
428 
429  namespace {
430  void resolvePutIndiciesImpl(void*,
431  BranchType iBranchType,
432  std::unordered_multimap<std::string, edm::ProductResolverIndex> const& iIndicies,
433  std::string const& iModuleLabel) {
434  //Do nothing
435  }
436 
437  void resolvePutIndiciesImpl(ProducerBase* iProd,
438  BranchType iBranchType,
439  std::unordered_multimap<std::string, edm::ProductResolverIndex> const& iIndicies,
440  std::string const& iModuleLabel) {
441  iProd->resolvePutIndicies(iBranchType, iIndicies, iModuleLabel);
442  }
443 
444  void resolvePutIndiciesImpl(edm::stream::EDProducerAdaptorBase* iProd,
445  BranchType iBranchType,
446  std::unordered_multimap<std::string, edm::ProductResolverIndex> const& iIndicies,
447  std::string const& iModuleLabel) {
448  iProd->resolvePutIndicies(iBranchType, iIndicies, iModuleLabel);
449  }
450  void resolvePutIndiciesImpl(edm::stream::EDFilterAdaptorBase* iProd,
451  BranchType iBranchType,
452  std::unordered_multimap<std::string, edm::ProductResolverIndex> const& iIndicies,
453  std::string const& iModuleLabel) {
454  iProd->resolvePutIndicies(iBranchType, iIndicies, iModuleLabel);
455  }
456 
457  std::vector<ProductResolverIndex> s_emptyIndexList;
458 
459  std::vector<ProductResolverIndex> const& itemsShouldPutInEventImpl(void const*) {
460  return s_emptyIndexList;
461  }
462 
463  std::vector<ProductResolverIndex> const& itemsShouldPutInEventImpl(ProducerBase const* iProd) {
464  return iProd->indiciesForPutProducts(edm::InEvent);
465  }
466 
467  std::vector<ProductResolverIndex> const& itemsShouldPutInEventImpl(edm::stream::EDProducerAdaptorBase const* iProd) {
468  return iProd->indiciesForPutProducts(edm::InEvent);
469  }
470 
471  std::vector<ProductResolverIndex> const& itemsShouldPutInEventImpl(edm::stream::EDFilterAdaptorBase const* iProd) {
472  return iProd->indiciesForPutProducts(edm::InEvent);
473  }
474 
475  }
476 
477  template<typename T>
479  std::unordered_multimap<std::string, edm::ProductResolverIndex> const& iIndicies) {
480  resolvePutIndiciesImpl(&module(), iBranchType,iIndicies, description().moduleLabel());
481  }
482 
483 
484  template<typename T>
485  std::vector<ProductResolverIndex> const&
487  return itemsShouldPutInEventImpl(&module());
488  }
489 
490 
491  template<>
493  template<>
495  template<>
497  template<>
499  template<>
501  template<>
503  template<>
505  template<>
507 
508  template<>
510  template<>
512  template<>
514  template<>
516 
517 
518  template<>
520  template<>
522  template<>
524 
525  //Explicitly instantiate our needed templates to avoid having the compiler
526  // instantiate them in all of our libraries
527  template class WorkerT<EDProducer>;
528  template class WorkerT<EDFilter>;
529  template class WorkerT<EDAnalyzer>;
530  template class WorkerT<OutputModule>;
531  template class WorkerT<one::EDProducerBase>;
532  template class WorkerT<one::EDFilterBase>;
533  template class WorkerT<one::EDAnalyzerBase>;
534  template class WorkerT<one::OutputModuleBase>;
535  template class WorkerT<global::EDProducerBase>;
536  template class WorkerT<global::EDFilterBase>;
537  template class WorkerT<global::EDAnalyzerBase>;
538  template class WorkerT<global::OutputModuleBase>;
542 }
virtual bool implDoStreamEnd(StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:196
static const char module_[]
ModuleDescription const & description() const
Definition: Worker.h:132
Definition: helper.py:1
roAction_t actions[nactions]
Definition: GenABIO.cc:187
void callWorkerStreamEnd(D, StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc)
Definition: WorkerT.cc:174
void resolvePutIndicies(BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
virtual void implEndJob() override
Definition: WorkerT.cc:293
virtual void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &) override
Definition: WorkerT.cc:424
T & module()
Definition: WorkerT.h:74
virtual bool implDoStreamBegin(StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:184
ActivityRegistry * activityRegistry()
Definition: Worker.h:206
virtual bool implDo(EventPrincipal const &ep, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:113
virtual ~WorkerT()
Definition: WorkerT.cc:107
#define constexpr
BranchType
Definition: BranchType.h:11
edm::propagate_const< std::shared_ptr< T > > module_
Definition: WorkerT.h:140
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts(BranchType iBranchType) const
Definition: ProducerBase.h:79
virtual void implRespondToOpenInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:332
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts(BranchType iBranchType) const
virtual bool implDoPrePrefetchSelection(StreamID id, EventPrincipal const &ep, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:121
virtual SerialTaskQueueChain * serializeRunModule() override
Definition: WorkerT.cc:369
void resolvePutIndicies(BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
Definition: ProducerBase.cc:85
void callWorkerEndStream(D, StreamID)
Definition: WorkerT.cc:315
void operator()(WorkerT< T > *iWorker, StreamID id)
Definition: WorkerT.cc:67
void operator()(const T &...)
Definition: WorkerT.cc:62
virtual void implBeginStream(StreamID) override
Definition: WorkerT.cc:306
Definition: value.py:1
void operator()(WorkerT< T > *iWorker, StreamID id)
Definition: WorkerT.cc:74
void callWorkerStreamBegin(D, StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc)
Definition: WorkerT.cc:165
virtual bool implDoBegin(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:157
virtual std::vector< ProductResolverIndex > const & itemsShouldPutInEvent() const override
Definition: WorkerT.cc:486
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:151
virtual void implEndStream(StreamID) override
Definition: WorkerT.cc:322
virtual void implBeginJob() override
Definition: WorkerT.cc:286
virtual void implPreForkReleaseResources() override
Definition: WorkerT.cc:346
virtual void implRespondToCloseInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:339
std::pair< OmniClusterRef, TrackingParticleRef > P
void callWorkerBeginStream(D, StreamID)
Definition: WorkerT.cc:299
HLT enums.
void postDoEvent(EventPrincipal const &)
Definition: Worker.cc:331
virtual void implRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &) override
Definition: WorkerT.cc:362
virtual bool implDoEnd(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:208
static Interceptor::Registry registry("Interceptor")
long double T
virtual std::string workerType() const override
Definition: WorkerT.cc:279
virtual void resolvePutIndicies(BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies) override
Definition: WorkerT.cc:478
WorkerT(std::shared_ptr< T >, ModuleDescription const &, ExceptionToActionTable const *actions)
Definition: WorkerT.cc:100
virtual void implPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren) override
Definition: WorkerT.cc:353
virtual Types moduleType() const override