CMS 3D CMS Logo

WorkerManager.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_WorkerManager_h
2 #define FWCore_Framework_WorkerManager_h
3 
4 /*
5 
6 */
7 
16 
17 #include <memory>
18 
19 #include <set>
20 #include <string>
21 #include <vector>
22 
23 namespace edm {
24  class ExceptionCollector;
25  class StreamID;
26  class StreamContext;
27  class ModuleRegistry;
28  class PreallocationConfiguration;
29 
30  class WorkerManager {
31  public:
32  typedef std::vector<Worker*> AllWorkers;
33 
34  WorkerManager(std::shared_ptr<ActivityRegistry> actReg, ExceptionToActionTable const& actions);
35 
36  WorkerManager(std::shared_ptr<ModuleRegistry> modReg,
37  std::shared_ptr<ActivityRegistry> actReg,
40  ProductRegistry& preg,
41  PreallocationConfiguration const* prealloc,
42  std::shared_ptr<ProcessConfiguration> processConfiguration,
44  std::set<std::string>& unscheduledLabels,
45  std::vector<std::string>& shouldBeUsedLabels);
46 
47  void setOnDemandProducts(ProductRegistry& pregistry, std::set<std::string> const& unscheduledLabels) const;
48 
49  template <typename T, typename U>
50  void processOneOccurrence(typename T::MyPrincipal& principal,
51  EventSetup const& eventSetup,
52  StreamID streamID,
53  typename T::Context const* topContext,
54  U const* context,
55  bool cleaningUpAfterException = false);
56  template <typename T, typename U>
58  WaitingTask* task,
59  typename T::MyPrincipal& principal,
60  EventSetup const& eventSetup,
61  StreamID streamID,
62  typename T::Context const* topContext,
63  U const* context);
64 
65 
67 
68  void beginJob(ProductRegistry const& iRegistry);
69  void endJob();
70  void endJob(ExceptionCollector& collector);
71 
72  void beginStream(StreamID iID, StreamContext& streamContext);
73  void endStream(StreamID iID, StreamContext& streamContext);
74 
75  AllWorkers const& allWorkers() const {return allWorkers_;}
76 
77  void addToAllWorkers(Worker* w);
78 
80 
82  ProductRegistry& preg,
83  PreallocationConfiguration const* prealloc,
84  std::shared_ptr<ProcessConfiguration const> processConfiguration,
85  std::string const& label);
86 
87  void resetAll();
88 
89  private:
90 
93  AllWorkers allWorkers_;
96  };
97 
98  template <typename T, typename U>
99  void
100  WorkerManager::processOneOccurrence(typename T::MyPrincipal& ep,
101  EventSetup const& es,
102  StreamID streamID,
103  typename T::Context const* topContext,
104  U const* context,
105  bool cleaningUpAfterException) {
106  this->resetAll();
107 
108  try {
109  convertException::wrap([&]() {
110  //make sure the unscheduled items see this run or lumi transition
111  unscheduled_.runNow<T,U>(ep, es,streamID, topContext, context);
112  }
113  );
114  }
115  catch(cms::Exception& ex) {
116  if (ex.context().empty()) {
117  addContextAndPrintException("Calling function WorkerManager::processOneOccurrence", ex, cleaningUpAfterException);
118  } else {
119  addContextAndPrintException("", ex, cleaningUpAfterException);
120  }
121  throw;
122  }
123  }
124 
125  template <typename T, typename U>
126  void
128  typename T::MyPrincipal& ep,
129  EventSetup const& es,
130  StreamID streamID,
131  typename T::Context const* topContext,
132  U const* context) {
133  //make sure the unscheduled items see this run or lumi transition
134  unscheduled_.runNowAsync<T,U>(task,ep, es,streamID, topContext, context);
135  }
136 
137 }
138 
139 #endif
roAction_t actions[nactions]
Definition: GenABIO.cc:187
void endStream(StreamID iID, StreamContext &streamContext)
const double w
Definition: UKUtility.cc:23
UnscheduledCallProducer unscheduled_
Definition: WorkerManager.h:94
void setOnDemandProducts(ProductRegistry &pregistry, std::set< std::string > const &unscheduledLabels) const
void addToUnscheduledWorkers(ParameterSet &pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration > processConfiguration, std::string label, std::set< std::string > &unscheduledLabels, std::vector< std::string > &shouldBeUsedLabels)
AllWorkers allWorkers_
Definition: WorkerManager.h:93
void processOneOccurrence(typename T::MyPrincipal &principal, EventSetup const &eventSetup, StreamID streamID, typename T::Context const *topContext, U const *context, bool cleaningUpAfterException=false)
void addContextAndPrintException(char const *context, cms::Exception &ex, bool disablePrint)
void beginJob(ProductRegistry const &iRegistry)
ExceptionToActionTable const * actionTable_
Definition: WorkerManager.h:92
void const * lastSetupEventPrincipal_
Definition: WorkerManager.h:95
void processOneOccurrenceAsync(WaitingTask *task, typename T::MyPrincipal &principal, EventSetup const &eventSetup, StreamID streamID, typename T::Context const *topContext, U const *context)
std::vector< Worker * > AllWorkers
Definition: WorkerManager.h:32
def principal(options)
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 beginStream(StreamID iID, StreamContext &streamContext)
AllWorkers const & allWorkers() const
Definition: WorkerManager.h:75
HLT enums.
void runNow(typename T::MyPrincipal &p, EventSetup const &es, StreamID streamID, typename T::Context const *topContext, U const *context) const
WorkerRegistry workerReg_
Definition: WorkerManager.h:91
The Registry of all workers that where requested Holds all instances of workers. In this implementati...
auto wrap(F iFunc) -> decltype(iFunc())
WorkerManager(std::shared_ptr< ActivityRegistry > actReg, ExceptionToActionTable const &actions)
long double T
Worker * getWorker(ParameterSet &pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration const > processConfiguration, std::string const &label)
ExceptionToActionTable const & actionTable() const
Definition: WorkerManager.h:79
void setupOnDemandSystem(EventPrincipal &principal, EventSetup const &es)
void addToAllWorkers(Worker *w)