test
CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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,
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 
57  void beginJob(ProductRegistry const& iRegistry);
58  void endJob();
59  void endJob(ExceptionCollector& collector);
60 
61  void beginStream(StreamID iID, StreamContext& streamContext);
62  void endStream(StreamID iID, StreamContext& streamContext);
63 
64  AllWorkers const& allWorkers() const {return allWorkers_;}
65 
66  void addToAllWorkers(Worker* w);
67 
69 
73  std::shared_ptr<ProcessConfiguration const> processConfiguration,
74  std::string const& label);
75 
76  private:
77 
78  void resetAll();
79 
86  };
87 
88  template <typename T, typename U>
89  void
90  WorkerManager::processOneOccurrence(typename T::MyPrincipal& ep,
91  EventSetup const& es,
92  StreamID streamID,
93  typename T::Context const* topContext,
94  U const* context,
95  bool cleaningUpAfterException) {
96  this->resetAll();
97 
98  try {
100  try {
101  if (T::isEvent_) {
102  setupOnDemandSystem(dynamic_cast<EventPrincipal&>(ep), es);
103  } else {
104  //make sure the unscheduled items see this run or lumi rtansition
105  unscheduled_.runNow<T,U>(ep, es,streamID, topContext, context);
106  }
107  }
108  catch(cms::Exception& e) {
112  if (action == exception_actions::SkipEvent) {
113  printCmsExceptionWarning("SkipEvent", e);
114  } else {
115  throw;
116  }
117  }
118  });
119  }
120  catch(cms::Exception& ex) {
121  if (ex.context().empty()) {
122  addContextAndPrintException("Calling function WorkerManager::processOneOccurrence", ex, cleaningUpAfterException);
123  } else {
124  addContextAndPrintException("", ex, cleaningUpAfterException);
125  }
126  throw;
127  }
128  }
129 }
130 
131 #endif
void endStream(StreamID iID, StreamContext &streamContext)
const double w
Definition: UKUtility.cc:23
UnscheduledCallProducer unscheduled_
Definition: WorkerManager.h:84
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:83
void processOneOccurrence(typename T::MyPrincipal &principal, EventSetup const &eventSetup, StreamID streamID, typename T::Context const *topContext, U const *context, bool cleaningUpAfterException=false)
Definition: WorkerManager.h:90
assert(m_qm.get())
void addContextAndPrintException(char const *context, cms::Exception &ex, bool disablePrint)
void beginJob(ProductRegistry const &iRegistry)
processConfiguration
Definition: Schedule.cc:383
std::string const & category() const
Definition: Exception.cc:183
exception_actions::ActionCodes find(const std::string &category) const
actions
Definition: Schedule.cc:383
ExceptionToActionTable const * actionTable_
Definition: WorkerManager.h:82
void const * lastSetupEventPrincipal_
Definition: WorkerManager.h:85
std::vector< Worker * > AllWorkers
Definition: WorkerManager.h:32
std::list< std::string > const & context() const
Definition: Exception.cc:191
void beginStream(StreamID iID, StreamContext &streamContext)
AllWorkers const & allWorkers() const
Definition: WorkerManager.h:64
string action
Definition: mps_fire.py:28
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:81
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)
preg
Definition: Schedule.cc:383
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:68
void setupOnDemandSystem(EventPrincipal &principal, EventSetup const &es)
prealloc
Definition: Schedule.cc:383
void addToAllWorkers(Worker *w)
void printCmsExceptionWarning(char const *behavior, cms::Exception const &e)