CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Worker.cc
Go to the documentation of this file.
1 
2 /*----------------------------------------------------------------------
3 ----------------------------------------------------------------------*/
4 
7 
8 namespace edm {
9  namespace {
10  class ModuleBeginJobSignalSentry {
11 public:
12  ModuleBeginJobSignalSentry(ActivityRegistry* a, ModuleDescription& md):a_(a), md_(&md) {
13  if(a_) a_->preModuleBeginJobSignal_(*md_);
14  }
15  ~ModuleBeginJobSignalSentry() {
16  if(a_) a_->postModuleBeginJobSignal_(*md_);
17  }
18 private:
19  ActivityRegistry* a_;
20  ModuleDescription* md_;
21  };
22 
23  class ModuleEndJobSignalSentry {
24 public:
25  ModuleEndJobSignalSentry(ActivityRegistry* a, ModuleDescription& md):a_(a), md_(&md) {
26  if(a_) a_->preModuleEndJobSignal_(*md_);
27  }
28  ~ModuleEndJobSignalSentry() {
29  if(a_) a_->postModuleEndJobSignal_(*md_);
30  }
31 private:
32  ActivityRegistry* a_;
33  ModuleDescription* md_;
34  };
35 
36  cms::Exception& exceptionContext(ModuleDescription const& iMD,
37  cms::Exception& iEx) {
38  iEx << iMD.moduleName() << "/" << iMD.moduleLabel() << "\n";
39  return iEx;
40  }
41 
42  }
43 
45  WorkerParams const& iWP) :
46  stopwatch_(),
47  timesRun_(),
48  timesVisited_(),
49  timesPassed_(),
50  timesFailed_(),
51  timesExcept_(),
52  state_(Ready),
53  md_(iMD),
54  actions_(iWP.actions_),
55  cached_exception_(),
56  actReg_(),
57  earlyDeleteHelper_(nullptr)
58  {
59  }
60 
62  }
63 
64  void Worker::setActivityRegistry(boost::shared_ptr<ActivityRegistry> areg) {
65  actReg_ = areg;
66  }
67 
69  earlyDeleteHelper_=iHelper;
70  }
71 
73  try {
74  try {
75  ModuleBeginJobSignalSentry cpp(actReg_.get(), md_);
76  implBeginJob();
77  }
78  catch (cms::Exception& e) { throw; }
79  catch(std::bad_alloc& bda) { convertException::badAllocToEDM(); }
82  catch(char const* c) { convertException::charPtrToEDM(c); }
83  catch (...) { convertException::unknownToEDM(); }
84  }
85  catch(cms::Exception& ex) {
86  state_ = Exception;
87  std::ostringstream ost;
88  ost << "Calling beginJob for module " << md_.moduleName() << "/'" << md_.moduleLabel() << "'";
89  ex.addContext(ost.str());
90  throw;
91  }
92  }
93 
94  void Worker::endJob() {
95  try {
96  try {
97  ModuleEndJobSignalSentry cpp(actReg_.get(), md_);
98  implEndJob();
99  }
100  catch (cms::Exception& e) { throw; }
101  catch(std::bad_alloc& bda) { convertException::badAllocToEDM(); }
102  catch (std::exception& e) { convertException::stdToEDM(e); }
104  catch(char const* c) { convertException::charPtrToEDM(c); }
105  catch (...) { convertException::unknownToEDM(); }
106  }
107  catch(cms::Exception& ex) {
108  state_ = Exception;
109  std::ostringstream ost;
110  ost << "Calling endJob for module " << md_.moduleName() << "/'" << md_.moduleLabel() << "'";
111  ex.addContext(ost.str());
112  throw;
113  }
114  }
115 
117  stopwatch_.reset(new RunStopwatch::StopwatchPointer::element_type);
118  }
119 
121  if(earlyDeleteHelper_) {
123  }
124  }
126  if(earlyDeleteHelper_) {
127  earlyDeleteHelper_->moduleRan(iEvent);
128  }
129  }
130 }
void pathFinished(EventPrincipal &)
Definition: Worker.cc:120
void setEarlyDeleteHelper(EarlyDeleteHelper *iHelper)
Definition: Worker.cc:68
virtual ~Worker()
Definition: Worker.cc:61
void endJob()
Definition: Worker.cc:94
boost::shared_ptr< ActivityRegistry > actReg_
Definition: Worker.h:150
#define nullptr
void setActivityRegistry(boost::shared_ptr< ActivityRegistry > areg)
Definition: Worker.cc:64
std::string const & moduleName() const
std::string const & moduleLabel() const
EarlyDeleteHelper * earlyDeleteHelper_
Definition: Worker.h:152
int iEvent
Definition: GenABIO.cc:243
void stdToEDM(std::exception const &e)
void useStopwatch()
Definition: Worker.cc:116
virtual void implEndJob()=0
void moduleRan(EventPrincipal &)
void postDoEvent(EventPrincipal &)
Definition: Worker.cc:125
void charPtrToEDM(char const *c)
void stringToEDM(std::string &s)
virtual void implBeginJob()=0
void addContext(std::string const &context)
Definition: Exception.cc:227
Worker(ModuleDescription const &iMD, WorkerParams const &iWP)
Definition: Worker.cc:44
ModuleDescription md_
Definition: Worker.h:146
double a
Definition: hdecay.h:121
void beginJob()
Definition: Worker.cc:72
RunStopwatch::StopwatchPointer stopwatch_
Definition: Worker.h:137
State state_
Definition: Worker.h:144
void pathFinished(EventPrincipal &)