Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-09-11 22:29:34

0001 #include "FWCore/Framework/interface/maker/WorkerT.h"
0002 #include "FWCore/Framework/interface/EventPrincipal.h"
0003 
0004 #include "FWCore/Framework/interface/EDProducer.h"
0005 #include "FWCore/Framework/interface/EDFilter.h"
0006 #include "FWCore/Framework/interface/EDAnalyzer.h"
0007 #include "FWCore/Framework/interface/one/EDProducerBase.h"
0008 #include "FWCore/Framework/interface/one/EDFilterBase.h"
0009 #include "FWCore/Framework/interface/one/EDAnalyzerBase.h"
0010 #include "FWCore/Framework/interface/one/OutputModuleBase.h"
0011 #include "FWCore/Framework/interface/global/EDProducerBase.h"
0012 #include "FWCore/Framework/interface/global/EDFilterBase.h"
0013 #include "FWCore/Framework/interface/global/EDAnalyzerBase.h"
0014 #include "FWCore/Framework/interface/global/OutputModuleBase.h"
0015 
0016 #include "FWCore/Framework/interface/stream/EDProducerAdaptorBase.h"
0017 #include "FWCore/Framework/interface/stream/EDFilterAdaptorBase.h"
0018 #include "FWCore/Framework/interface/stream/EDAnalyzerAdaptorBase.h"
0019 
0020 #include "FWCore/Framework/interface/limited/EDProducerBase.h"
0021 #include "FWCore/Framework/interface/limited/EDFilterBase.h"
0022 #include "FWCore/Framework/interface/limited/EDAnalyzerBase.h"
0023 #include "FWCore/Framework/interface/limited/OutputModuleBase.h"
0024 
0025 #include <type_traits>
0026 
0027 namespace edm {
0028   namespace workerimpl {
0029     template <typename T>
0030     struct has_stream_functions {
0031       static bool constexpr value = false;
0032     };
0033 
0034     template <>
0035     struct has_stream_functions<edm::global::EDProducerBase> {
0036       static bool constexpr value = true;
0037     };
0038 
0039     template <>
0040     struct has_stream_functions<edm::global::EDFilterBase> {
0041       static bool constexpr value = true;
0042     };
0043 
0044     template <>
0045     struct has_stream_functions<edm::global::EDAnalyzerBase> {
0046       static bool constexpr value = true;
0047     };
0048 
0049     template <>
0050     struct has_stream_functions<edm::limited::EDProducerBase> {
0051       static bool constexpr value = true;
0052     };
0053 
0054     template <>
0055     struct has_stream_functions<edm::limited::EDFilterBase> {
0056       static bool constexpr value = true;
0057     };
0058 
0059     template <>
0060     struct has_stream_functions<edm::limited::EDAnalyzerBase> {
0061       static bool constexpr value = true;
0062     };
0063 
0064     template <>
0065     struct has_stream_functions<edm::stream::EDProducerAdaptorBase> {
0066       static bool constexpr value = true;
0067     };
0068 
0069     template <>
0070     struct has_stream_functions<edm::stream::EDFilterAdaptorBase> {
0071       static bool constexpr value = true;
0072     };
0073 
0074     template <>
0075     struct has_stream_functions<edm::stream::EDAnalyzerAdaptorBase> {
0076       static bool constexpr value = true;
0077     };
0078 
0079     template <typename T>
0080     struct has_only_stream_transition_functions {
0081       static bool constexpr value = false;
0082     };
0083 
0084     template <>
0085     struct has_only_stream_transition_functions<edm::global::OutputModuleBase> {
0086       static bool constexpr value = true;
0087     };
0088 
0089     struct DoNothing {
0090       template <typename... T>
0091       inline void operator()(const T&...) {}
0092     };
0093 
0094     template <typename T>
0095     struct DoBeginStream {
0096       inline void operator()(WorkerT<T>* iWorker, StreamID id) { iWorker->callWorkerBeginStream(0, id); }
0097     };
0098 
0099     template <typename T>
0100     struct DoEndStream {
0101       inline void operator()(WorkerT<T>* iWorker, StreamID id) { iWorker->callWorkerEndStream(0, id); }
0102     };
0103 
0104     template <typename T, typename INFOTYPE>
0105     struct DoStreamBeginTrans {
0106       inline void operator()(WorkerT<T>* iWorker, StreamID id, INFOTYPE const& info, ModuleCallingContext const* mcc) {
0107         iWorker->callWorkerStreamBegin(0, id, info, mcc);
0108       }
0109     };
0110 
0111     template <typename T, typename INFOTYPE>
0112     struct DoStreamEndTrans {
0113       inline void operator()(WorkerT<T>* iWorker, StreamID id, INFOTYPE const& info, ModuleCallingContext const* mcc) {
0114         iWorker->callWorkerStreamEnd(0, id, info, mcc);
0115       }
0116     };
0117   }  // namespace workerimpl
0118 
0119   template <typename T>
0120   inline WorkerT<T>::WorkerT(std::shared_ptr<T> ed, ModuleDescription const& md, ExceptionToActionTable const* actions)
0121       : Worker(md, actions), module_(ed) {
0122     assert(module_ != nullptr);
0123   }
0124 
0125   template <typename T>
0126   WorkerT<T>::~WorkerT() {}
0127 
0128   template <typename T>
0129   bool WorkerT<T>::wantsProcessBlocks() const {
0130     return module_->wantsProcessBlocks();
0131   }
0132 
0133   template <typename T>
0134   bool WorkerT<T>::wantsInputProcessBlocks() const {
0135     return module_->wantsInputProcessBlocks();
0136   }
0137 
0138   template <typename T>
0139   bool WorkerT<T>::wantsGlobalRuns() const {
0140     return module_->wantsGlobalRuns();
0141   }
0142 
0143   template <typename T>
0144   bool WorkerT<T>::wantsGlobalLuminosityBlocks() const {
0145     return module_->wantsGlobalLuminosityBlocks();
0146   }
0147 
0148   template <typename T>
0149   bool WorkerT<T>::wantsStreamRuns() const {
0150     return module_->wantsStreamRuns();
0151   }
0152 
0153   template <typename T>
0154   bool WorkerT<T>::wantsStreamLuminosityBlocks() const {
0155     return module_->wantsStreamLuminosityBlocks();
0156   }
0157 
0158   template <typename T>
0159   SerialTaskQueue* WorkerT<T>::globalRunsQueue() {
0160     return nullptr;
0161   }
0162   template <typename T>
0163   SerialTaskQueue* WorkerT<T>::globalLuminosityBlocksQueue() {
0164     return nullptr;
0165   }
0166   template <>
0167   SerialTaskQueue* WorkerT<EDProducer>::globalRunsQueue() {
0168     return module_->globalRunsQueue();
0169   }
0170   template <>
0171   SerialTaskQueue* WorkerT<EDProducer>::globalLuminosityBlocksQueue() {
0172     return module_->globalLuminosityBlocksQueue();
0173   }
0174   template <>
0175   SerialTaskQueue* WorkerT<EDFilter>::globalRunsQueue() {
0176     return module_->globalRunsQueue();
0177   }
0178   template <>
0179   SerialTaskQueue* WorkerT<EDFilter>::globalLuminosityBlocksQueue() {
0180     return module_->globalLuminosityBlocksQueue();
0181   }
0182   template <>
0183   SerialTaskQueue* WorkerT<EDAnalyzer>::globalRunsQueue() {
0184     return module_->globalRunsQueue();
0185   }
0186   template <>
0187   SerialTaskQueue* WorkerT<EDAnalyzer>::globalLuminosityBlocksQueue() {
0188     return module_->globalLuminosityBlocksQueue();
0189   }
0190   //one
0191   template <>
0192   SerialTaskQueue* WorkerT<one::EDProducerBase>::globalRunsQueue() {
0193     return module_->globalRunsQueue();
0194   }
0195   template <>
0196   SerialTaskQueue* WorkerT<one::EDProducerBase>::globalLuminosityBlocksQueue() {
0197     return module_->globalLuminosityBlocksQueue();
0198   }
0199   template <>
0200   SerialTaskQueue* WorkerT<one::EDFilterBase>::globalRunsQueue() {
0201     return module_->globalRunsQueue();
0202   }
0203   template <>
0204   SerialTaskQueue* WorkerT<one::EDFilterBase>::globalLuminosityBlocksQueue() {
0205     return module_->globalLuminosityBlocksQueue();
0206   }
0207   template <>
0208   SerialTaskQueue* WorkerT<one::EDAnalyzerBase>::globalRunsQueue() {
0209     return module_->globalRunsQueue();
0210   }
0211   template <>
0212   SerialTaskQueue* WorkerT<one::EDAnalyzerBase>::globalLuminosityBlocksQueue() {
0213     return module_->globalLuminosityBlocksQueue();
0214   }
0215   template <>
0216   SerialTaskQueue* WorkerT<one::OutputModuleBase>::globalRunsQueue() {
0217     return module_->globalRunsQueue();
0218   }
0219   template <>
0220   SerialTaskQueue* WorkerT<one::OutputModuleBase>::globalLuminosityBlocksQueue() {
0221     return module_->globalLuminosityBlocksQueue();
0222   }
0223 
0224   template <typename T>
0225   inline bool WorkerT<T>::implDo(EventTransitionInfo const& info, ModuleCallingContext const* mcc) {
0226     EventPrincipal const& ep = info.principal();
0227     std::shared_ptr<Worker> sentry(this, [&ep](Worker* obj) { obj->postDoEvent(ep); });
0228     return module_->doEvent(info, activityRegistry(), mcc);
0229   }
0230 
0231   template <typename T>
0232   inline void WorkerT<T>::implDoAcquire(EventTransitionInfo const&,
0233                                         ModuleCallingContext const*,
0234                                         WaitingTaskWithArenaHolder&) {}
0235 
0236   template <>
0237   inline void WorkerT<global::EDProducerBase>::implDoAcquire(EventTransitionInfo const& info,
0238                                                              ModuleCallingContext const* mcc,
0239                                                              WaitingTaskWithArenaHolder& holder) {
0240     module_->doAcquire(info, activityRegistry(), mcc, holder);
0241   }
0242 
0243   template <>
0244   inline void WorkerT<global::EDFilterBase>::implDoAcquire(EventTransitionInfo const& info,
0245                                                            ModuleCallingContext const* mcc,
0246                                                            WaitingTaskWithArenaHolder& holder) {
0247     module_->doAcquire(info, activityRegistry(), mcc, holder);
0248   }
0249 
0250   template <>
0251   inline void WorkerT<global::OutputModuleBase>::implDoAcquire(EventTransitionInfo const& info,
0252                                                                ModuleCallingContext const* mcc,
0253                                                                WaitingTaskWithArenaHolder& holder) {
0254     module_->doAcquire(info, activityRegistry(), mcc, holder);
0255   }
0256 
0257   template <>
0258   inline void WorkerT<stream::EDProducerAdaptorBase>::implDoAcquire(EventTransitionInfo const& info,
0259                                                                     ModuleCallingContext const* mcc,
0260                                                                     WaitingTaskWithArenaHolder& holder) {
0261     module_->doAcquire(info, activityRegistry(), mcc, holder);
0262   }
0263 
0264   template <>
0265   inline void WorkerT<stream::EDFilterAdaptorBase>::implDoAcquire(EventTransitionInfo const& info,
0266                                                                   ModuleCallingContext const* mcc,
0267                                                                   WaitingTaskWithArenaHolder& holder) {
0268     module_->doAcquire(info, activityRegistry(), mcc, holder);
0269   }
0270 
0271   template <typename T>
0272   inline void WorkerT<T>::implDoTransform(size_t iTransformIndex, EventPrincipal const&, ParentContext const&) {}
0273   template <>
0274   inline void WorkerT<global::EDFilterBase>::implDoTransform(size_t iTransformIndex,
0275                                                              EventPrincipal const& iEvent,
0276                                                              ParentContext const& iParent) {
0277     ModuleCallingContext mcc(
0278         &module_->moduleDescription(), ModuleCallingContext::State::kPrefetching, iParent, nullptr);
0279     module_->doTransform(iTransformIndex, iEvent, activityRegistry(), &mcc);
0280   }
0281   template <>
0282   inline void WorkerT<global::EDProducerBase>::implDoTransform(size_t iTransformIndex,
0283                                                                EventPrincipal const& iEvent,
0284                                                                ParentContext const& iParent) {
0285     ModuleCallingContext mcc(
0286         &module_->moduleDescription(), ModuleCallingContext::State::kPrefetching, iParent, nullptr);
0287     module_->doTransform(iTransformIndex, iEvent, activityRegistry(), &mcc);
0288   }
0289   template <>
0290   inline void WorkerT<stream::EDProducerAdaptorBase>::implDoTransform(size_t iTransformIndex,
0291                                                                       EventPrincipal const& iEvent,
0292                                                                       ParentContext const& iParent) {
0293     ModuleCallingContext mcc(
0294         &module_->moduleDescription(), ModuleCallingContext::State::kPrefetching, iParent, nullptr);
0295     module_->doTransform(iTransformIndex, iEvent, activityRegistry(), &mcc);
0296   }
0297   template <>
0298   inline void WorkerT<limited::EDFilterBase>::implDoTransform(size_t iTransformIndex,
0299                                                               EventPrincipal const& iEvent,
0300                                                               ParentContext const& iParent) {
0301     ModuleCallingContext mcc(
0302         &module_->moduleDescription(), ModuleCallingContext::State::kPrefetching, iParent, nullptr);
0303     module_->doTransform(iTransformIndex, iEvent, activityRegistry(), &mcc);
0304   }
0305   template <>
0306   inline void WorkerT<limited::EDProducerBase>::implDoTransform(size_t iTransformIndex,
0307                                                                 EventPrincipal const& iEvent,
0308                                                                 ParentContext const& iParent) {
0309     ModuleCallingContext mcc(
0310         &module_->moduleDescription(), ModuleCallingContext::State::kPrefetching, iParent, nullptr);
0311     module_->doTransform(iTransformIndex, iEvent, activityRegistry(), &mcc);
0312   }
0313   template <>
0314   inline void WorkerT<one::EDFilterBase>::implDoTransform(size_t iTransformIndex,
0315                                                           EventPrincipal const& iEvent,
0316                                                           ParentContext const& iParent) {
0317     ModuleCallingContext mcc(
0318         &module_->moduleDescription(), ModuleCallingContext::State::kPrefetching, iParent, nullptr);
0319     module_->doTransform(iTransformIndex, iEvent, activityRegistry(), &mcc);
0320   }
0321   template <>
0322   inline void WorkerT<one::EDProducerBase>::implDoTransform(size_t iTransformIndex,
0323                                                             EventPrincipal const& iEvent,
0324                                                             ParentContext const& iParent) {
0325     ModuleCallingContext mcc(
0326         &module_->moduleDescription(), ModuleCallingContext::State::kPrefetching, iParent, nullptr);
0327     module_->doTransform(iTransformIndex, iEvent, activityRegistry(), &mcc);
0328   }
0329 
0330   template <typename T>
0331   inline size_t WorkerT<T>::transformIndex(edm::BranchDescription const&) const {
0332     return -1;
0333   }
0334   template <>
0335   inline size_t WorkerT<global::EDFilterBase>::transformIndex(edm::BranchDescription const& iBranch) const {
0336     return module_->transformIndex_(iBranch);
0337   }
0338   template <>
0339   inline size_t WorkerT<global::EDProducerBase>::transformIndex(edm::BranchDescription const& iBranch) const {
0340     return module_->transformIndex_(iBranch);
0341   }
0342   template <>
0343   inline size_t WorkerT<stream::EDProducerAdaptorBase>::transformIndex(edm::BranchDescription const& iBranch) const {
0344     return module_->transformIndex_(iBranch);
0345   }
0346   template <>
0347   inline size_t WorkerT<limited::EDFilterBase>::transformIndex(edm::BranchDescription const& iBranch) const {
0348     return module_->transformIndex_(iBranch);
0349   }
0350   template <>
0351   inline size_t WorkerT<limited::EDProducerBase>::transformIndex(edm::BranchDescription const& iBranch) const {
0352     return module_->transformIndex_(iBranch);
0353   }
0354   template <>
0355   inline size_t WorkerT<one::EDFilterBase>::transformIndex(edm::BranchDescription const& iBranch) const {
0356     return module_->transformIndex_(iBranch);
0357   }
0358   template <>
0359   inline size_t WorkerT<one::EDProducerBase>::transformIndex(edm::BranchDescription const& iBranch) const {
0360     return module_->transformIndex_(iBranch);
0361   }
0362 
0363   template <typename T>
0364   inline ProductResolverIndex WorkerT<T>::itemToGetForTransform(size_t iTransformIndex) const {
0365     return -1;
0366   }
0367   template <>
0368   inline ProductResolverIndex WorkerT<global::EDFilterBase>::itemToGetForTransform(size_t iTransformIndex) const {
0369     return module_->transformPrefetch_(iTransformIndex);
0370   }
0371   template <>
0372   inline ProductResolverIndex WorkerT<global::EDProducerBase>::itemToGetForTransform(size_t iTransformIndex) const {
0373     return module_->transformPrefetch_(iTransformIndex);
0374   }
0375   template <>
0376   inline ProductResolverIndex WorkerT<stream::EDProducerAdaptorBase>::itemToGetForTransform(
0377       size_t iTransformIndex) const {
0378     return module_->transformPrefetch_(iTransformIndex);
0379   }
0380   template <>
0381   inline ProductResolverIndex WorkerT<limited::EDFilterBase>::itemToGetForTransform(size_t iTransformIndex) const {
0382     return module_->transformPrefetch_(iTransformIndex);
0383   }
0384   template <>
0385   inline ProductResolverIndex WorkerT<limited::EDProducerBase>::itemToGetForTransform(size_t iTransformIndex) const {
0386     return module_->transformPrefetch_(iTransformIndex);
0387   }
0388   template <>
0389   inline ProductResolverIndex WorkerT<one::EDFilterBase>::itemToGetForTransform(size_t iTransformIndex) const {
0390     return module_->transformPrefetch_(iTransformIndex);
0391   }
0392   template <>
0393   inline ProductResolverIndex WorkerT<one::EDProducerBase>::itemToGetForTransform(size_t iTransformIndex) const {
0394     return module_->transformPrefetch_(iTransformIndex);
0395   }
0396 
0397   template <typename T>
0398   inline bool WorkerT<T>::implNeedToRunSelection() const {
0399     return false;
0400   }
0401 
0402   template <typename T>
0403   inline bool WorkerT<T>::implDoPrePrefetchSelection(StreamID id,
0404                                                      EventPrincipal const& ep,
0405                                                      ModuleCallingContext const* mcc) {
0406     return true;
0407   }
0408   template <typename T>
0409   inline void WorkerT<T>::itemsToGetForSelection(std::vector<ProductResolverIndexAndSkipBit>&) const {}
0410 
0411   template <>
0412   inline bool WorkerT<edm::one::OutputModuleBase>::implNeedToRunSelection() const {
0413     return true;
0414   }
0415 
0416   template <>
0417   inline bool WorkerT<edm::one::OutputModuleBase>::implDoPrePrefetchSelection(StreamID id,
0418                                                                               EventPrincipal const& ep,
0419                                                                               ModuleCallingContext const* mcc) {
0420     return module_->prePrefetchSelection(id, ep, mcc);
0421   }
0422   template <>
0423   inline void WorkerT<edm::one::OutputModuleBase>::itemsToGetForSelection(
0424       std::vector<ProductResolverIndexAndSkipBit>& iItems) const {
0425     iItems = module_->productsUsedBySelection();
0426   }
0427 
0428   template <>
0429   inline bool WorkerT<edm::global::OutputModuleBase>::implNeedToRunSelection() const {
0430     return true;
0431   }
0432   template <>
0433   inline bool WorkerT<edm::global::OutputModuleBase>::implDoPrePrefetchSelection(StreamID id,
0434                                                                                  EventPrincipal const& ep,
0435                                                                                  ModuleCallingContext const* mcc) {
0436     return module_->prePrefetchSelection(id, ep, mcc);
0437   }
0438   template <>
0439   inline void WorkerT<edm::global::OutputModuleBase>::itemsToGetForSelection(
0440       std::vector<ProductResolverIndexAndSkipBit>& iItems) const {
0441     iItems = module_->productsUsedBySelection();
0442   }
0443 
0444   template <>
0445   inline bool WorkerT<edm::limited::OutputModuleBase>::implNeedToRunSelection() const {
0446     return true;
0447   }
0448   template <>
0449   inline bool WorkerT<edm::limited::OutputModuleBase>::implDoPrePrefetchSelection(StreamID id,
0450                                                                                   EventPrincipal const& ep,
0451                                                                                   ModuleCallingContext const* mcc) {
0452     return module_->prePrefetchSelection(id, ep, mcc);
0453   }
0454   template <>
0455   inline void WorkerT<edm::limited::OutputModuleBase>::itemsToGetForSelection(
0456       std::vector<ProductResolverIndexAndSkipBit>& iItems) const {
0457     iItems = module_->productsUsedBySelection();
0458   }
0459 
0460   template <typename T>
0461   bool WorkerT<T>::implDoBeginProcessBlock(ProcessBlockPrincipal const& pbp, ModuleCallingContext const* mcc) {
0462     module_->doBeginProcessBlock(pbp, mcc);
0463     return true;
0464   }
0465 
0466   template <typename T>
0467   bool WorkerT<T>::implDoAccessInputProcessBlock(ProcessBlockPrincipal const& pbp, ModuleCallingContext const* mcc) {
0468     module_->doAccessInputProcessBlock(pbp, mcc);
0469     return true;
0470   }
0471 
0472   template <typename T>
0473   bool WorkerT<T>::implDoEndProcessBlock(ProcessBlockPrincipal const& pbp, ModuleCallingContext const* mcc) {
0474     module_->doEndProcessBlock(pbp, mcc);
0475     return true;
0476   }
0477 
0478   template <typename T>
0479   inline bool WorkerT<T>::implDoBegin(RunTransitionInfo const& info, ModuleCallingContext const* mcc) {
0480     module_->doBeginRun(info, mcc);
0481     return true;
0482   }
0483 
0484   template <typename T>
0485   template <typename D>
0486   void WorkerT<T>::callWorkerStreamBegin(D,
0487                                          StreamID id,
0488                                          RunTransitionInfo const& info,
0489                                          ModuleCallingContext const* mcc) {
0490     module_->doStreamBeginRun(id, info, mcc);
0491   }
0492 
0493   template <typename T>
0494   template <typename D>
0495   void WorkerT<T>::callWorkerStreamEnd(D, StreamID id, RunTransitionInfo const& info, ModuleCallingContext const* mcc) {
0496     module_->doStreamEndRun(id, info, mcc);
0497   }
0498 
0499   template <typename T>
0500   inline bool WorkerT<T>::implDoStreamBegin(StreamID id,
0501                                             RunTransitionInfo const& info,
0502                                             ModuleCallingContext const* mcc) {
0503     std::conditional_t<workerimpl::has_stream_functions<T>::value,
0504                        workerimpl::DoStreamBeginTrans<T, RunTransitionInfo const>,
0505                        workerimpl::DoNothing>
0506         might_call;
0507     might_call(this, id, info, mcc);
0508     return true;
0509   }
0510 
0511   template <typename T>
0512   inline bool WorkerT<T>::implDoStreamEnd(StreamID id, RunTransitionInfo const& info, ModuleCallingContext const* mcc) {
0513     std::conditional_t<workerimpl::has_stream_functions<T>::value,
0514                        workerimpl::DoStreamEndTrans<T, RunTransitionInfo const>,
0515                        workerimpl::DoNothing>
0516         might_call;
0517     might_call(this, id, info, mcc);
0518     return true;
0519   }
0520 
0521   template <typename T>
0522   inline bool WorkerT<T>::implDoEnd(RunTransitionInfo const& info, ModuleCallingContext const* mcc) {
0523     module_->doEndRun(info, mcc);
0524     return true;
0525   }
0526 
0527   template <typename T>
0528   inline bool WorkerT<T>::implDoBegin(LumiTransitionInfo const& info, ModuleCallingContext const* mcc) {
0529     module_->doBeginLuminosityBlock(info, mcc);
0530     return true;
0531   }
0532 
0533   template <typename T>
0534   template <typename D>
0535   void WorkerT<T>::callWorkerStreamBegin(D,
0536                                          StreamID id,
0537                                          LumiTransitionInfo const& info,
0538                                          ModuleCallingContext const* mcc) {
0539     module_->doStreamBeginLuminosityBlock(id, info, mcc);
0540   }
0541 
0542   template <typename T>
0543   template <typename D>
0544   void WorkerT<T>::callWorkerStreamEnd(D, StreamID id, LumiTransitionInfo const& info, ModuleCallingContext const* mcc) {
0545     module_->doStreamEndLuminosityBlock(id, info, mcc);
0546   }
0547 
0548   template <typename T>
0549   inline bool WorkerT<T>::implDoStreamBegin(StreamID id,
0550                                             LumiTransitionInfo const& info,
0551                                             ModuleCallingContext const* mcc) {
0552     std::conditional_t<workerimpl::has_stream_functions<T>::value,
0553                        workerimpl::DoStreamBeginTrans<T, LumiTransitionInfo>,
0554                        workerimpl::DoNothing>
0555         might_call;
0556     might_call(this, id, info, mcc);
0557     return true;
0558   }
0559 
0560   template <typename T>
0561   inline bool WorkerT<T>::implDoStreamEnd(StreamID id,
0562                                           LumiTransitionInfo const& info,
0563                                           ModuleCallingContext const* mcc) {
0564     std::conditional_t<workerimpl::has_stream_functions<T>::value,
0565                        workerimpl::DoStreamEndTrans<T, LumiTransitionInfo>,
0566                        workerimpl::DoNothing>
0567         might_call;
0568     might_call(this, id, info, mcc);
0569 
0570     return true;
0571   }
0572 
0573   template <typename T>
0574   inline bool WorkerT<T>::implDoEnd(LumiTransitionInfo const& info, ModuleCallingContext const* mcc) {
0575     module_->doEndLuminosityBlock(info, mcc);
0576     return true;
0577   }
0578 
0579   template <typename T>
0580   inline std::string WorkerT<T>::workerType() const {
0581     return module_->workerType();
0582   }
0583 
0584   template <typename T>
0585   inline void WorkerT<T>::implBeginJob() {
0586     module_->doBeginJob();
0587   }
0588 
0589   template <typename T>
0590   inline void WorkerT<T>::implEndJob() {
0591     module_->doEndJob();
0592   }
0593 
0594   template <typename T>
0595   template <typename D>
0596   void WorkerT<T>::callWorkerBeginStream(D, StreamID id) {
0597     module_->doBeginStream(id);
0598   }
0599 
0600   template <typename T>
0601   inline void WorkerT<T>::implBeginStream(StreamID id) {
0602     std::conditional_t<workerimpl::has_stream_functions<T>::value or
0603                            workerimpl::has_only_stream_transition_functions<T>::value,
0604                        workerimpl::DoBeginStream<T>,
0605                        workerimpl::DoNothing>
0606         might_call;
0607     might_call(this, id);
0608   }
0609 
0610   template <typename T>
0611   template <typename D>
0612   void WorkerT<T>::callWorkerEndStream(D, StreamID id) {
0613     module_->doEndStream(id);
0614   }
0615 
0616   template <typename T>
0617   inline void WorkerT<T>::implEndStream(StreamID id) {
0618     std::conditional_t<workerimpl::has_stream_functions<T>::value or
0619                            workerimpl::has_only_stream_transition_functions<T>::value,
0620                        workerimpl::DoEndStream<T>,
0621                        workerimpl::DoNothing>
0622         might_call;
0623     might_call(this, id);
0624   }
0625 
0626   template <typename T>
0627   inline void WorkerT<T>::implRespondToOpenInputFile(FileBlock const& fb) {
0628     module_->doRespondToOpenInputFile(fb);
0629   }
0630 
0631   template <typename T>
0632   inline void WorkerT<T>::implRespondToCloseInputFile(FileBlock const& fb) {
0633     module_->doRespondToCloseInputFile(fb);
0634   }
0635 
0636   template <typename T>
0637   void WorkerT<T>::implRespondToCloseOutputFile() {
0638     module_->doRespondToCloseOutputFile();
0639   }
0640 
0641   template <typename T>
0642   inline void WorkerT<T>::implRegisterThinnedAssociations(ProductRegistry const& registry,
0643                                                           ThinnedAssociationsHelper& helper) {
0644     module_->doRegisterThinnedAssociations(registry, helper);
0645   }
0646 
0647   template <typename T>
0648   inline Worker::TaskQueueAdaptor WorkerT<T>::serializeRunModule() {
0649     return Worker::TaskQueueAdaptor{};
0650   }
0651   template <>
0652   Worker::TaskQueueAdaptor WorkerT<EDAnalyzer>::serializeRunModule() {
0653     return &(module_->sharedResourcesAcquirer().serialQueueChain());
0654   }
0655   template <>
0656   Worker::TaskQueueAdaptor WorkerT<EDFilter>::serializeRunModule() {
0657     return &(module_->sharedResourcesAcquirer().serialQueueChain());
0658   }
0659   template <>
0660   Worker::TaskQueueAdaptor WorkerT<EDProducer>::serializeRunModule() {
0661     return &(module_->sharedResourcesAcquirer().serialQueueChain());
0662   }
0663   template <>
0664   Worker::TaskQueueAdaptor WorkerT<one::EDAnalyzerBase>::serializeRunModule() {
0665     return &(module_->sharedResourcesAcquirer().serialQueueChain());
0666   }
0667   template <>
0668   Worker::TaskQueueAdaptor WorkerT<one::EDFilterBase>::serializeRunModule() {
0669     return &(module_->sharedResourcesAcquirer().serialQueueChain());
0670   }
0671   template <>
0672   Worker::TaskQueueAdaptor WorkerT<one::EDProducerBase>::serializeRunModule() {
0673     return &(module_->sharedResourcesAcquirer().serialQueueChain());
0674   }
0675   template <>
0676   Worker::TaskQueueAdaptor WorkerT<one::OutputModuleBase>::serializeRunModule() {
0677     return &(module_->sharedResourcesAcquirer().serialQueueChain());
0678   }
0679   template <>
0680   Worker::TaskQueueAdaptor WorkerT<limited::EDAnalyzerBase>::serializeRunModule() {
0681     return &(module_->queue());
0682   }
0683   template <>
0684   Worker::TaskQueueAdaptor WorkerT<limited::EDFilterBase>::serializeRunModule() {
0685     return &(module_->queue());
0686   }
0687   template <>
0688   Worker::TaskQueueAdaptor WorkerT<limited::EDProducerBase>::serializeRunModule() {
0689     return &(module_->queue());
0690   }
0691   template <>
0692   Worker::TaskQueueAdaptor WorkerT<limited::OutputModuleBase>::serializeRunModule() {
0693     return &(module_->queue());
0694   }
0695 
0696   namespace {
0697     template <typename T>
0698     bool mustPrefetchMayGet();
0699 
0700     template <>
0701     bool mustPrefetchMayGet<EDAnalyzer>() {
0702       return true;
0703     }
0704     template <>
0705     bool mustPrefetchMayGet<EDProducer>() {
0706       return true;
0707     }
0708     template <>
0709     bool mustPrefetchMayGet<EDFilter>() {
0710       return true;
0711     }
0712 
0713     template <>
0714     bool mustPrefetchMayGet<edm::one::EDProducerBase>() {
0715       return true;
0716     }
0717     template <>
0718     bool mustPrefetchMayGet<edm::one::EDFilterBase>() {
0719       return true;
0720     }
0721     template <>
0722     bool mustPrefetchMayGet<edm::one::EDAnalyzerBase>() {
0723       return true;
0724     }
0725     template <>
0726     bool mustPrefetchMayGet<edm::one::OutputModuleBase>() {
0727       return true;
0728     }
0729 
0730     template <>
0731     bool mustPrefetchMayGet<edm::global::EDProducerBase>() {
0732       return true;
0733     }
0734     template <>
0735     bool mustPrefetchMayGet<edm::global::EDFilterBase>() {
0736       return true;
0737     }
0738     template <>
0739     bool mustPrefetchMayGet<edm::global::EDAnalyzerBase>() {
0740       return true;
0741     }
0742     template <>
0743     bool mustPrefetchMayGet<edm::global::OutputModuleBase>() {
0744       return true;
0745     }
0746 
0747     template <>
0748     bool mustPrefetchMayGet<edm::limited::EDProducerBase>() {
0749       return true;
0750     }
0751     template <>
0752     bool mustPrefetchMayGet<edm::limited::EDFilterBase>() {
0753       return true;
0754     }
0755     template <>
0756     bool mustPrefetchMayGet<edm::limited::EDAnalyzerBase>() {
0757       return true;
0758     }
0759     template <>
0760     bool mustPrefetchMayGet<edm::limited::OutputModuleBase>() {
0761       return true;
0762     }
0763 
0764     template <>
0765     bool mustPrefetchMayGet<edm::stream::EDProducerAdaptorBase>() {
0766       return true;
0767     }
0768     template <>
0769     bool mustPrefetchMayGet<edm::stream::EDFilterAdaptorBase>() {
0770       return true;
0771     }
0772     template <>
0773     bool mustPrefetchMayGet<edm::stream::EDAnalyzerAdaptorBase>() {
0774       return true;
0775     }
0776 
0777   }  // namespace
0778 
0779   template <typename T>
0780   void WorkerT<T>::updateLookup(BranchType iBranchType, ProductResolverIndexHelper const& iHelper) {
0781     module_->updateLookup(iBranchType, iHelper, mustPrefetchMayGet<T>());
0782   }
0783 
0784   template <typename T>
0785   void WorkerT<T>::updateLookup(eventsetup::ESRecordsToProxyIndices const& iPI) {
0786     module_->updateLookup(iPI);
0787   }
0788 
0789   template <typename T>
0790   void WorkerT<T>::selectInputProcessBlocks(ProductRegistry const& productRegistry,
0791                                             ProcessBlockHelperBase const& processBlockHelperBase) {
0792     module_->selectInputProcessBlocks(productRegistry, processBlockHelperBase);
0793   }
0794 
0795   namespace {
0796     using ModuleToResolverIndicies =
0797         std::unordered_multimap<std::string, std::tuple<edm::TypeID const*, const char*, edm::ProductResolverIndex>>;
0798     void resolvePutIndiciesImpl(void*,
0799                                 BranchType iBranchType,
0800                                 ModuleToResolverIndicies const& iIndicies,
0801                                 std::string const& iModuleLabel) {
0802       //Do nothing
0803     }
0804 
0805     void resolvePutIndiciesImpl(ProducerBase* iProd,
0806                                 BranchType iBranchType,
0807                                 ModuleToResolverIndicies const& iIndicies,
0808                                 std::string const& iModuleLabel) {
0809       iProd->resolvePutIndicies(iBranchType, iIndicies, iModuleLabel);
0810     }
0811 
0812     void resolvePutIndiciesImpl(edm::stream::EDProducerAdaptorBase* iProd,
0813                                 BranchType iBranchType,
0814                                 ModuleToResolverIndicies const& iIndicies,
0815                                 std::string const& iModuleLabel) {
0816       iProd->resolvePutIndicies(iBranchType, iIndicies, iModuleLabel);
0817     }
0818     void resolvePutIndiciesImpl(edm::stream::EDFilterAdaptorBase* iProd,
0819                                 BranchType iBranchType,
0820                                 ModuleToResolverIndicies const& iIndicies,
0821                                 std::string const& iModuleLabel) {
0822       iProd->resolvePutIndicies(iBranchType, iIndicies, iModuleLabel);
0823     }
0824 
0825   }  // namespace
0826 
0827   template <typename T>
0828   void WorkerT<T>::resolvePutIndicies(
0829       BranchType iBranchType,
0830       std::unordered_multimap<std::string, std::tuple<TypeID const*, const char*, edm::ProductResolverIndex>> const&
0831           iIndicies) {
0832     resolvePutIndiciesImpl(&module(), iBranchType, iIndicies, description()->moduleLabel());
0833   }
0834 
0835   template <>
0836   Worker::Types WorkerT<EDAnalyzer>::moduleType() const {
0837     return Worker::kAnalyzer;
0838   }
0839   template <>
0840   Worker::Types WorkerT<EDProducer>::moduleType() const {
0841     return Worker::kProducer;
0842   }
0843   template <>
0844   Worker::Types WorkerT<EDFilter>::moduleType() const {
0845     return Worker::kFilter;
0846   }
0847   template <>
0848   Worker::Types WorkerT<edm::one::EDProducerBase>::moduleType() const {
0849     return Worker::kProducer;
0850   }
0851   template <>
0852   Worker::Types WorkerT<edm::one::EDFilterBase>::moduleType() const {
0853     return Worker::kFilter;
0854   }
0855   template <>
0856   Worker::Types WorkerT<edm::one::EDAnalyzerBase>::moduleType() const {
0857     return Worker::kAnalyzer;
0858   }
0859   template <>
0860   Worker::Types WorkerT<edm::one::OutputModuleBase>::moduleType() const {
0861     return Worker::kOutputModule;
0862   }
0863 
0864   template <>
0865   Worker::Types WorkerT<edm::global::EDProducerBase>::moduleType() const {
0866     return Worker::kProducer;
0867   }
0868   template <>
0869   Worker::Types WorkerT<edm::global::EDFilterBase>::moduleType() const {
0870     return Worker::kFilter;
0871   }
0872   template <>
0873   Worker::Types WorkerT<edm::global::EDAnalyzerBase>::moduleType() const {
0874     return Worker::kAnalyzer;
0875   }
0876   template <>
0877   Worker::Types WorkerT<edm::global::OutputModuleBase>::moduleType() const {
0878     return Worker::kOutputModule;
0879   }
0880 
0881   template <>
0882   Worker::Types WorkerT<edm::limited::EDProducerBase>::moduleType() const {
0883     return Worker::kProducer;
0884   }
0885   template <>
0886   Worker::Types WorkerT<edm::limited::EDFilterBase>::moduleType() const {
0887     return Worker::kFilter;
0888   }
0889   template <>
0890   Worker::Types WorkerT<edm::limited::EDAnalyzerBase>::moduleType() const {
0891     return Worker::kAnalyzer;
0892   }
0893   template <>
0894   Worker::Types WorkerT<edm::limited::OutputModuleBase>::moduleType() const {
0895     return Worker::kOutputModule;
0896   }
0897 
0898   template <>
0899   Worker::Types WorkerT<edm::stream::EDProducerAdaptorBase>::moduleType() const {
0900     return Worker::kProducer;
0901   }
0902   template <>
0903   Worker::Types WorkerT<edm::stream::EDFilterAdaptorBase>::moduleType() const {
0904     return Worker::kFilter;
0905   }
0906   template <>
0907   Worker::Types WorkerT<edm::stream::EDAnalyzerAdaptorBase>::moduleType() const {
0908     return Worker::kAnalyzer;
0909   }
0910 
0911   template <>
0912   Worker::ConcurrencyTypes WorkerT<EDAnalyzer>::moduleConcurrencyType() const {
0913     return Worker::kLegacy;
0914   }
0915   template <>
0916   Worker::ConcurrencyTypes WorkerT<EDProducer>::moduleConcurrencyType() const {
0917     return Worker::kLegacy;
0918   }
0919   template <>
0920   Worker::ConcurrencyTypes WorkerT<EDFilter>::moduleConcurrencyType() const {
0921     return Worker::kLegacy;
0922   }
0923   template <>
0924   Worker::ConcurrencyTypes WorkerT<edm::one::EDProducerBase>::moduleConcurrencyType() const {
0925     return Worker::kOne;
0926   }
0927   template <>
0928   Worker::ConcurrencyTypes WorkerT<edm::one::EDFilterBase>::moduleConcurrencyType() const {
0929     return Worker::kOne;
0930   }
0931   template <>
0932   Worker::ConcurrencyTypes WorkerT<edm::one::EDAnalyzerBase>::moduleConcurrencyType() const {
0933     return Worker::kOne;
0934   }
0935   template <>
0936   Worker::ConcurrencyTypes WorkerT<edm::one::OutputModuleBase>::moduleConcurrencyType() const {
0937     return Worker::kOne;
0938   }
0939 
0940   template <>
0941   Worker::ConcurrencyTypes WorkerT<edm::global::EDProducerBase>::moduleConcurrencyType() const {
0942     return Worker::kGlobal;
0943   }
0944   template <>
0945   Worker::ConcurrencyTypes WorkerT<edm::global::EDFilterBase>::moduleConcurrencyType() const {
0946     return Worker::kGlobal;
0947   }
0948   template <>
0949   Worker::ConcurrencyTypes WorkerT<edm::global::EDAnalyzerBase>::moduleConcurrencyType() const {
0950     return Worker::kGlobal;
0951   }
0952   template <>
0953   Worker::ConcurrencyTypes WorkerT<edm::global::OutputModuleBase>::moduleConcurrencyType() const {
0954     return Worker::kGlobal;
0955   }
0956 
0957   template <>
0958   Worker::ConcurrencyTypes WorkerT<edm::limited::EDProducerBase>::moduleConcurrencyType() const {
0959     return Worker::kLimited;
0960   }
0961   template <>
0962   Worker::ConcurrencyTypes WorkerT<edm::limited::EDFilterBase>::moduleConcurrencyType() const {
0963     return Worker::kLimited;
0964   }
0965   template <>
0966   Worker::ConcurrencyTypes WorkerT<edm::limited::EDAnalyzerBase>::moduleConcurrencyType() const {
0967     return Worker::kLimited;
0968   }
0969   template <>
0970   Worker::ConcurrencyTypes WorkerT<edm::limited::OutputModuleBase>::moduleConcurrencyType() const {
0971     return Worker::kLimited;
0972   }
0973 
0974   template <>
0975   Worker::ConcurrencyTypes WorkerT<edm::stream::EDProducerAdaptorBase>::moduleConcurrencyType() const {
0976     return Worker::kStream;
0977   }
0978   template <>
0979   Worker::ConcurrencyTypes WorkerT<edm::stream::EDFilterAdaptorBase>::moduleConcurrencyType() const {
0980     return Worker::kStream;
0981   }
0982   template <>
0983   Worker::ConcurrencyTypes WorkerT<edm::stream::EDAnalyzerAdaptorBase>::moduleConcurrencyType() const {
0984     return Worker::kStream;
0985   }
0986 
0987   //Explicitly instantiate our needed templates to avoid having the compiler
0988   // instantiate them in all of our libraries
0989   template class WorkerT<EDProducer>;
0990   template class WorkerT<EDFilter>;
0991   template class WorkerT<EDAnalyzer>;
0992   template class WorkerT<one::EDProducerBase>;
0993   template class WorkerT<one::EDFilterBase>;
0994   template class WorkerT<one::EDAnalyzerBase>;
0995   template class WorkerT<one::OutputModuleBase>;
0996   template class WorkerT<global::EDProducerBase>;
0997   template class WorkerT<global::EDFilterBase>;
0998   template class WorkerT<global::EDAnalyzerBase>;
0999   template class WorkerT<global::OutputModuleBase>;
1000   template class WorkerT<stream::EDProducerAdaptorBase>;
1001   template class WorkerT<stream::EDFilterAdaptorBase>;
1002   template class WorkerT<stream::EDAnalyzerAdaptorBase>;
1003   template class WorkerT<limited::EDProducerBase>;
1004   template class WorkerT<limited::EDFilterBase>;
1005   template class WorkerT<limited::EDAnalyzerBase>;
1006   template class WorkerT<limited::OutputModuleBase>;
1007 }  // namespace edm