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(0 != aWorker);
47  unscheduledWorkers_.push_back(aWorker);
48  }
49 
50  void setEventSetup(EventSetup const& iSetup) {
51  aux_.setEventSetup(&iSetup);
52  }
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>
60  void runNow(typename T::MyPrincipal& p, EventSetup const& es, StreamID streamID,
61  typename T::Context const* topContext, U const* context) const {
62  //do nothing for event since we will run when requested
63  if(!T::isEvent_) {
64  for(auto worker: unscheduledWorkers_) {
65  try {
66  ParentContext parentContext(context);
67  worker->doWork<T>(p, es, streamID, parentContext, topContext);
68  }
69  catch (cms::Exception & ex) {
70  if(ex.context().empty()) {
71  addContextToException<T>(ex,worker,p.id());
72  }
73  throw;
74  }
75  }
76  }
77  }
78 
79  template <typename T, typename U>
81  typename T::MyPrincipal& p, EventSetup const& es, StreamID streamID,
82  typename T::Context const* topContext, U const* context) const {
83  //do nothing for event since we will run when requested
84  if(!T::isEvent_) {
85  for(auto worker: unscheduledWorkers_) {
86  ParentContext parentContext(context);
87  worker->doWorkNoPrefetchingAsync<T>(task, p, es, streamID, parentContext, topContext);
88  }
89  }
90  }
91 
92 
93  private:
94  template <typename T, typename ID>
95  void addContextToException(cms::Exception& ex, Worker const* worker, ID const& id) const {
96  std::ostringstream ost;
97  ost << "Processing " << T::transitionName()<<" "<< id;
98  ex.addContext(ost.str());
99  }
102  };
103 
104 }
105 
106 #endif
107 
PostModuleEventDelayedGet postModuleEventDelayedGetSignal_
PreModuleEventDelayedGet preModuleEventDelayedGetSignal_
UnscheduledCallProducer(ActivityRegistry &iReg)
uint32_t ID
Definition: Definitions.h:26
std::vector< Worker * > worker_container
void runNowAsync(WaitingTask *task, typename T::MyPrincipal &p, EventSetup const &es, StreamID streamID, typename T::Context const *topContext, U const *context) const
std::list< std::string > const & context() const
Definition: Exception.cc:191
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:227
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> preModuleDelayedGetSignal_
HLT enums.
void setEventSetup(EventSetup const *iSetup)
void runNow(typename T::MyPrincipal &p, EventSetup const &es, StreamID streamID, typename T::Context const *topContext, U const *context) const
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:63