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