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 
15 
16 #include "boost/shared_ptr.hpp"
17 
18 #include <set>
19 #include <string>
20 #include <vector>
21 
22 namespace edm {
23  class ExceptionCollector;
24  class StreamID;
25  class StreamContext;
26  class ModuleRegistry;
27  class PreallocationConfiguration;
28 
29  class WorkerManager {
30  public:
31  typedef std::vector<Worker*> AllWorkers;
32 
33  WorkerManager(boost::shared_ptr<ActivityRegistry> actReg, ExceptionToActionTable const& actions);
34 
35  WorkerManager(boost::shared_ptr<ModuleRegistry> modReg,
36  boost::shared_ptr<ActivityRegistry> actReg,
41  boost::shared_ptr<ProcessConfiguration> processConfiguration,
43  bool useStopwatch,
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, bool useStopwatch);
67 
69 
73  boost::shared_ptr<ProcessConfiguration const> processConfiguration,
74  std::string const& label);
75 
76  private:
77 
78  void resetAll();
79 
81 
84 
86 
87  boost::shared_ptr<UnscheduledCallProducer> unscheduled_;
88  };
89 
90  template <typename T, typename U>
91  void
92  WorkerManager::processOneOccurrence(typename T::MyPrincipal& ep,
93  EventSetup const& es,
94  StreamID streamID,
95  typename T::Context const* topContext,
96  U const* context,
97  bool cleaningUpAfterException) {
98  this->resetAll();
99 
100  try {
101  convertException::wrap([&]() {
102  try {
103  if (T::isEvent_) {
104  setupOnDemandSystem(dynamic_cast<EventPrincipal&>(ep), es);
105  } else {
106  //make sure the unscheduled items see this run or lumi rtansition
107  unscheduled_->runNow<T,U>(ep, es,streamID, topContext, context);
108  }
109  }
110  catch(cms::Exception& e) {
112  assert (action != exception_actions::IgnoreCompletely);
113  assert (action != exception_actions::FailPath);
114  if (action == exception_actions::SkipEvent) {
115  printCmsExceptionWarning("SkipEvent", e);
116  } else {
117  throw;
118  }
119  }
120  });
121  }
122  catch(cms::Exception& ex) {
123  if (ex.context().empty()) {
124  addContextAndPrintException("Calling function WorkerManager::processOneOccurrence", ex, cleaningUpAfterException);
125  } else {
126  addContextAndPrintException("", ex, cleaningUpAfterException);
127  }
128  throw;
129  }
130  }
131 }
132 
133 #endif
void endStream(StreamID iID, StreamContext &streamContext)
const double w
Definition: UKUtility.cc:23
void setOnDemandProducts(ProductRegistry &pregistry, std::set< std::string > const &unscheduledLabels) const
AllWorkers allWorkers_
Definition: WorkerManager.h:85
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:92
void addToUnscheduledWorkers(ParameterSet &pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, boost::shared_ptr< ProcessConfiguration > processConfiguration, std::string label, bool useStopwatch, std::set< std::string > &unscheduledLabels, std::vector< std::string > &shouldBeUsedLabels)
void addContextAndPrintException(char const *context, cms::Exception &ex, bool disablePrint)
void beginJob(ProductRegistry const &iRegistry)
processConfiguration
Definition: Schedule.cc:369
std::string const & category() const
Definition: Exception.cc:183
exception_actions::ActionCodes find(const std::string &category) const
actions
Definition: Schedule.cc:369
ExceptionToActionTable const * actionTable_
Definition: WorkerManager.h:83
std::vector< Worker * > AllWorkers
Definition: WorkerManager.h:31
Worker * getWorker(ParameterSet &pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, boost::shared_ptr< ProcessConfiguration const > processConfiguration, std::string const &label)
std::list< std::string > const & context() const
Definition: Exception.cc:191
void printCmsExceptionWarning(char const *behavior, cms::Exception const &e, edm::JobReport *jobRep=0, int rc=-1)
boost::shared_ptr< UnscheduledCallProducer > unscheduled_
Definition: WorkerManager.h:87
void beginStream(StreamID iID, StreamContext &streamContext)
AllWorkers const & allWorkers() const
Definition: WorkerManager.h:64
WorkerManager(boost::shared_ptr< ActivityRegistry > actReg, ExceptionToActionTable const &actions)
WorkerRegistry workerReg_
Definition: WorkerManager.h:82
The Registry of all workers that where requested Holds all instances of workers. In this implementati...
auto wrap(F iFunc) -> decltype(iFunc())
void addToAllWorkers(Worker *w, bool useStopwatch)
preg
Definition: Schedule.cc:369
long double T
ExceptionToActionTable const & actionTable() const
Definition: WorkerManager.h:68
void setupOnDemandSystem(EventPrincipal &principal, EventSetup const &es)
prealloc
Definition: Schedule.cc:369