CMS 3D CMS Logo

UnscheduledCallProducer.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_UnscheduledCallProducer_h
2 #define FWCore_Framework_UnscheduledCallProducer_h
3 
4 // -*- C++ -*-
5 //
6 // Package: FWCore/Framework
7 // Class : UnscheduledCallProducer
8 //
25 
26 #include <vector>
27 #include <unordered_map>
28 #include <string>
29 #include <sstream>
30 
31 namespace edm {
32 
33  class ModuleCallingContext;
34 
36  public:
37 
38  using worker_container = std::vector<Worker*>;
39  using const_iterator = worker_container::const_iterator;
40 
44  }
45  void addWorker(Worker* aWorker) {
46  assert(nullptr != aWorker);
47  unscheduledWorkers_.push_back(aWorker);
48  if (aWorker->hasAccumulator()) {
49  accumulatorWorkers_.push_back(aWorker);
50  }
51  }
52 
53  void setEventSetup(EventSetup const& iSetup) {
54  aux_.setEventSetup(&iSetup);
55  }
56 
57  UnscheduledAuxiliary const& auxiliary() const { return aux_; }
58 
59  const_iterator begin() const { return unscheduledWorkers_.begin(); }
60  const_iterator end() const { return unscheduledWorkers_.end(); }
61 
62  template <typename T, typename U>
64  typename T::MyPrincipal& p, EventSetup const& es,
65  ServiceToken const& token, StreamID streamID,
66  typename T::Context const* topContext, U const* context) const {
67  //do nothing for event since we will run when requested
68  if(!T::isEvent_) {
69  for(auto worker: unscheduledWorkers_) {
70  ParentContext parentContext(context);
71 
72  // We do not need to run prefetching here because this only handles
73  // stream transitions for runs and lumis. There are no products put
74  // into the runs or lumis in stream transitions, so there can be
75  // no data dependencies which require prefetching. Prefetching is
76  // needed for global transitions, but they are run elsewhere.
77  worker->doWorkNoPrefetchingAsync<T>(task, p, es, token, streamID, parentContext, topContext);
78  }
79  }
80  }
81 
82  template <typename T>
84  typename T::MyPrincipal const& ep,
85  EventSetup const& es,
86  ServiceToken const& token,
87  StreamID streamID,
88  ParentContext const& parentContext,
89  typename T::Context const* context) {
90  for (auto worker : accumulatorWorkers_) {
91  worker->doWorkAsync<T>(task, ep, es, token, streamID, parentContext, context);
92  }
93  }
94 
95  private:
96  template <typename T, typename ID>
97  void addContextToException(cms::Exception& ex, Worker const* worker, ID const& id) const {
98  std::ostringstream ost;
99  ost << "Processing " << T::transitionName()<<" "<< id;
100  ex.addContext(ost.str());
101  }
105  };
106 
107 }
108 
109 #endif
110 
PostModuleEventDelayedGet postModuleEventDelayedGetSignal_
PreModuleEventDelayedGet preModuleEventDelayedGetSignal_
UnscheduledCallProducer(ActivityRegistry &iReg)
uint32_t ID
Definition: Definitions.h:26
std::vector< Worker * > worker_container
void addContextToException(cms::Exception &ex, Worker const *worker, ID const &id) const
void runNowAsync(WaitingTask *task, typename T::MyPrincipal &p, EventSetup const &es, ServiceToken const &token, StreamID streamID, typename T::Context const *topContext, U const *context) const
UnscheduledAuxiliary const & auxiliary() const
void addContext(std::string const &context)
Definition: Exception.cc:227
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> preModuleDelayedGetSignal_
virtual bool hasAccumulator() const =0
HLT enums.
void setEventSetup(EventSetup const *iSetup)
void runAccumulatorsAsync(WaitingTask *task, typename T::MyPrincipal const &ep, EventSetup const &es, ServiceToken const &token, StreamID streamID, ParentContext const &parentContext, typename T::Context const *context)
void setEventSetup(EventSetup const &iSetup)
worker_container::const_iterator const_iterator
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> postModuleDelayedGetSignal_
long double T
void connect(U iFunc)
Definition: Signal.h:64