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:
27  enum FilterAction { Normal = 0, Ignore, Veto };
28 
29  WorkerInPath(Worker*, FilterAction theAction, unsigned int placeInPath);
30 
31  template <typename T>
32  void runWorkerAsync(WaitingTask* iTask,
33  typename T::MyPrincipal const&,
34  EventSetupImpl const&,
35  ServiceToken const&,
36  StreamID streamID,
37  typename T::Context const* context);
38 
39  bool checkResultsOfRunWorker(bool wasEvent);
40 
41  void skipWorker(EventPrincipal const& iPrincipal) { worker_->skipOnPath(); }
42  void skipWorker(RunPrincipal const&) {}
44 
46 
47  int timesVisited() const { return timesVisited_; }
48  int timesPassed() const { return timesPassed_; }
49  int timesFailed() const { return timesFailed_; }
50  int timesExcept() const { return timesExcept_; }
51 
53  Worker* getWorker() const { return worker_; }
54 
56 
57  private:
62 
65 
67  };
68 
69  inline bool WorkerInPath::checkResultsOfRunWorker(bool wasEvent) {
70  if (not wasEvent) {
71  return true;
72  }
73  auto state = worker_->state();
74  bool rc = true;
75  switch (state) {
76  case Worker::Fail: {
77  rc = false;
78  break;
79  }
80  case Worker::Pass:
81  break;
82  case Worker::Exception: {
83  ++timesExcept_;
84  return true;
85  }
86 
87  default:
88  assert(false);
89  }
90 
91  if (Ignore == filterAction()) {
92  rc = true;
93  } else if (Veto == filterAction()) {
94  rc = !rc;
95  }
96 
97  if (rc) {
98  ++timesPassed_;
99  } else {
100  ++timesFailed_;
101  }
102  return rc;
103  }
104 
105  template <typename T>
107  typename T::MyPrincipal const& ep,
108  EventSetupImpl const& es,
109  ServiceToken const& token,
110  StreamID streamID,
111  typename T::Context const* context) {
112  if (T::isEvent_) {
113  ++timesVisited_;
114  }
115 
116  if (T::isEvent_) {
117  ParentContext parentContext(&placeInPathContext_);
118  worker_->doWorkAsync<T>(iTask, ep, es, token, streamID, parentContext, context);
119  } else {
120  ParentContext parentContext(context);
121 
122  // We do not need to run prefetching here because this only handles
123  // stream transitions for runs and lumis. There are no products put
124  // into the runs or lumis in stream transitions, so there can be
125  // no data dependencies which require prefetching. Prefetching is
126  // needed for global transitions, but they are run elsewhere.
127  worker_->doWorkNoPrefetchingAsync<T>(iTask, ep, es, token, streamID, parentContext, context);
128  }
129  }
130 } // namespace edm
131 
132 #endif
int timesVisited() const
Definition: WorkerInPath.h:47
void skipOnPath()
Definition: Worker.cc:362
void setPathContext(PathContext const *v)
bool checkResultsOfRunWorker(bool wasEvent)
Definition: WorkerInPath.h:69
int timesExcept() const
Definition: WorkerInPath.h:50
State state() const
Definition: Worker.h:232
void skipWorker(EventPrincipal const &iPrincipal)
Definition: WorkerInPath.h:41
FilterAction filterAction() const
Definition: WorkerInPath.h:52
void doWorkNoPrefetchingAsync(WaitingTask *task, typename T::MyPrincipal const &, EventSetupImpl const &c, ServiceToken const &token, StreamID stream, ParentContext const &parentContext, typename T::Context const *context)
Definition: Worker.h:926
void setPathContext(PathContext const *v)
Definition: WorkerInPath.h:55
void skipWorker(RunPrincipal const &)
Definition: WorkerInPath.h:42
void runWorkerAsync(WaitingTask *iTask, typename T::MyPrincipal const &, EventSetupImpl const &, ServiceToken const &, StreamID streamID, typename T::Context const *context)
Definition: WorkerInPath.h:106
Worker * getWorker() const
Definition: WorkerInPath.h:53
FilterAction filterAction_
Definition: WorkerInPath.h:63
void skipWorker(LuminosityBlockPrincipal const &)
Definition: WorkerInPath.h:43
PlaceInPathContext placeInPathContext_
Definition: WorkerInPath.h:66
HLT enums.
int timesFailed() const
Definition: WorkerInPath.h:49
WorkerInPath(Worker *, FilterAction theAction, unsigned int placeInPath)
Definition: WorkerInPath.cc:6
int timesPassed() const
Definition: WorkerInPath.h:48
void doWorkAsync(WaitingTask *task, typename T::MyPrincipal const &, EventSetupImpl const &c, ServiceToken const &token, StreamID stream, ParentContext const &parentContext, typename T::Context const *context)
Definition: Worker.h:827
long double T