CMS 3D CMS Logo

WorkerInPath.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_WorkerInPath_h
2 #define FWCore_Framework_WorkerInPath_h
3 
4 /*
5 
6  Author: Jim Kowalkowski 28-01-06
7 
8 
9  A wrapper around a Worker, so that statistics can be managed
10  per path. A Path holds Workers as these things.
11 
12 */
13 
17 
18 namespace edm {
19 
20  class PathContext;
21  class StreamID;
22  class WaitingTask;
23  class ServiceToken;
24 
25  class WorkerInPath {
26  public:
28 
29  WorkerInPath(Worker*, FilterAction theAction, unsigned int placeInPath);
30 
31  template <typename T>
32  void runWorkerAsync(WaitingTask* iTask,
33  typename T::MyPrincipal const&, EventSetup const&,
34  ServiceToken const&,
35  StreamID streamID,
36  typename T::Context const* context);
37 
38 
39  bool checkResultsOfRunWorker(bool wasEvent);
40 
41  void skipWorker(EventPrincipal const& iPrincipal) {
43  }
44  void skipWorker(RunPrincipal const&) {}
46 
47  void clearCounters() {
49  }
50 
51  int timesVisited() const { return timesVisited_; }
52  int timesPassed() const { return timesPassed_; }
53  int timesFailed() const { return timesFailed_; }
54  int timesExcept() const { return timesExcept_; }
55 
57  Worker* getWorker() const { return worker_; }
58 
60 
61  private:
66 
69 
71  };
72 
73  inline bool WorkerInPath::checkResultsOfRunWorker(bool wasEvent) {
74  if(not wasEvent) {
75  return true;
76  }
77  auto state = worker_->state();
78  bool rc = true;
79  switch (state) {
80  case Worker::Fail:
81  {
82  rc = false;
83  break;
84  }
85  case Worker::Pass:
86  break;
87  case Worker::Exception:
88  {
89  ++timesExcept_;
90  return true;
91  }
92 
93  default:
94  assert(false);
95  }
96 
97  if(Ignore == filterAction()) {
98  rc = true;
99  } else if(Veto == filterAction()) {
100  rc = !rc;
101  }
102 
103  if(rc) {
104  ++timesPassed_;
105  } else {
106  ++timesFailed_;
107  }
108  return rc;
109 
110  }
111 
112  template <typename T>
114  typename T::MyPrincipal const& ep, EventSetup const & es,
115  ServiceToken const& token,
116  StreamID streamID,
117  typename T::Context const* context) {
118  if (T::isEvent_) {
119  ++timesVisited_;
120  }
121 
122  if(T::isEvent_) {
123  ParentContext parentContext(&placeInPathContext_);
124  worker_->doWorkAsync<T>(iTask,ep, es, token, streamID, parentContext, context);
125  } else {
126  ParentContext parentContext(context);
127 
128  // We do not need to run prefetching here because this only handles
129  // stream transitions for runs and lumis. There are no products put
130  // into the runs or lumis in stream transitions, so there can be
131  // no data dependencies which require prefetching. Prefetching is
132  // needed for global transitions, but they are run elsewhere.
133  worker_->doWorkNoPrefetchingAsync<T>(iTask,ep, es,token, streamID, parentContext, context);
134  }
135  }
136 }
137 
138 #endif
139 
int timesVisited() const
Definition: WorkerInPath.h:51
void skipOnPath()
Definition: Worker.cc:369
void setPathContext(PathContext const *v)
bool checkResultsOfRunWorker(bool wasEvent)
Definition: WorkerInPath.h:73
int timesExcept() const
Definition: WorkerInPath.h:54
State state() const
Definition: Worker.h:229
void skipWorker(EventPrincipal const &iPrincipal)
Definition: WorkerInPath.h:41
void doWorkNoPrefetchingAsync(WaitingTask *task, typename T::MyPrincipal const &, EventSetup const &c, ServiceToken const &token, StreamID stream, ParentContext const &parentContext, typename T::Context const *context)
Definition: Worker.h:954
FilterAction filterAction() const
Definition: WorkerInPath.h:56
void setPathContext(PathContext const *v)
Definition: WorkerInPath.h:59
void skipWorker(RunPrincipal const &)
Definition: WorkerInPath.h:44
Worker * getWorker() const
Definition: WorkerInPath.h:57
FilterAction filterAction_
Definition: WorkerInPath.h:67
void skipWorker(LuminosityBlockPrincipal const &)
Definition: WorkerInPath.h:45
PlaceInPathContext placeInPathContext_
Definition: WorkerInPath.h:70
void doWorkAsync(WaitingTask *task, typename T::MyPrincipal const &, EventSetup const &c, ServiceToken const &token, StreamID stream, ParentContext const &parentContext, typename T::Context const *context)
Definition: Worker.h:852
void runWorkerAsync(WaitingTask *iTask, typename T::MyPrincipal const &, EventSetup const &, ServiceToken const &, StreamID streamID, typename T::Context const *context)
Definition: WorkerInPath.h:113
HLT enums.
int timesFailed() const
Definition: WorkerInPath.h:53
WorkerInPath(Worker *, FilterAction theAction, unsigned int placeInPath)
Definition: WorkerInPath.cc:6
int timesPassed() const
Definition: WorkerInPath.h:52
long double T