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  using worker_container = std::vector<Worker*>;
38  using const_iterator = worker_container::const_iterator;
39 
43  }
44  void addWorker(Worker* aWorker) {
45  assert(nullptr != aWorker);
46  unscheduledWorkers_.push_back(aWorker);
47  if (aWorker->hasAccumulator()) {
48  accumulatorWorkers_.push_back(aWorker);
49  }
50  }
51 
52  void setEventSetup(EventSetupImpl const& iSetup) { aux_.setEventSetup(&iSetup); }
53 
54  UnscheduledAuxiliary const& auxiliary() const { return aux_; }
55 
56  const_iterator begin() const { return unscheduledWorkers_.begin(); }
57  const_iterator end() const { return unscheduledWorkers_.end(); }
58 
59  template <typename T, typename U>
61  typename T::MyPrincipal& p,
62  EventSetupImpl const& es,
63  ServiceToken const& token,
64  StreamID streamID,
65  typename T::Context const* topContext,
66  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  EventSetupImpl 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 } // namespace edm
108 
109 #endif
PostModuleEventDelayedGet postModuleEventDelayedGetSignal_
PreModuleEventDelayedGet preModuleEventDelayedGetSignal_
UnscheduledCallProducer(ActivityRegistry &iReg)
uint32_t ID
Definition: Definitions.h:26
std::vector< Worker * > worker_container
void setEventSetup(EventSetupImpl const *iSetup)
void setEventSetup(EventSetupImpl const &iSetup)
void runAccumulatorsAsync(WaitingTask *task, typename T::MyPrincipal const &ep, EventSetupImpl const &es, ServiceToken const &token, StreamID streamID, ParentContext const &parentContext, typename T::Context const *context)
void addContextToException(cms::Exception &ex, Worker const *worker, ID const &id) const
UnscheduledAuxiliary const & auxiliary() const
void addContext(std::string const &context)
Definition: Exception.cc:165
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> preModuleDelayedGetSignal_
virtual bool hasAccumulator() const =0
HLT enums.
worker_container::const_iterator const_iterator
void runNowAsync(WaitingTask *task, typename T::MyPrincipal &p, EventSetupImpl const &es, ServiceToken const &token, StreamID streamID, typename T::Context const *topContext, U const *context) const
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> postModuleDelayedGetSignal_
long double T
void connect(U iFunc)
Definition: Signal.h:62