CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
56 
57  private:
62 
65 
68  };
69 
70  inline bool WorkerInPath::checkResultsOfRunWorker(bool wasEvent) {
71  if (not wasEvent) {
72  return true;
73  }
74  auto state = worker_->state();
75  bool rc = true;
76  switch (state) {
77  case Worker::Fail: {
78  rc = false;
79  break;
80  }
81  case Worker::Pass:
82  break;
83  case Worker::Exception: {
84  ++timesExcept_;
85  return true;
86  }
87 
88  default:
89  assert(false);
90  }
91 
92  if (Ignore == filterAction()) {
93  rc = true;
94  } else if (Veto == filterAction()) {
95  rc = !rc;
96  }
97 
98  if (rc) {
99  ++timesPassed_;
100  } else {
101  ++timesFailed_;
102  }
103  return rc;
104  }
105 
106  template <typename T>
108  typename T::TransitionInfoType const& info,
109  ServiceToken const& token,
110  StreamID streamID,
111  typename T::Context const* context) {
112  if constexpr (T::isEvent_) {
113  ++timesVisited_;
114  }
115 
116  if constexpr (T::isEvent_) {
117  ParentContext parentContext(&placeInPathContext_);
118  worker_->doWorkAsync<T>(iTask, info, 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, info, token, streamID, parentContext, context);
128  }
129  }
130 } // namespace edm
131 
132 #endif
int timesVisited() const
Definition: WorkerInPath.h:46
static const TGPicture * info(bool iBackgroundIsBlack)
void setPathContext(PathContext const *v)
bool checkResultsOfRunWorker(bool wasEvent)
Definition: WorkerInPath.h:70
int timesExcept() const
Definition: WorkerInPath.h:49
State state() const
Definition: Worker.h:237
void doWorkAsync(WaitingTaskHolder, typename T::TransitionInfoType const &, ServiceToken const &, StreamID, ParentContext const &, typename T::Context const *)
Definition: Worker.h:931
void skipWorker(EventPrincipal const &iPrincipal)
Definition: WorkerInPath.h:40
assert(be >=bs)
FilterAction filterAction() const
Definition: WorkerInPath.h:51
void setPathContext(PathContext const *v)
Definition: WorkerInPath.h:55
WorkerInPath(Worker *, FilterAction theAction, unsigned int placeInPath, bool runConcurrently)
Definition: WorkerInPath.cc:6
void skipWorker(RunPrincipal const &)
Definition: WorkerInPath.h:41
Worker * getWorker() const
Definition: WorkerInPath.h:52
void doWorkNoPrefetchingAsync(WaitingTaskHolder, typename T::TransitionInfoType const &, ServiceToken const &, StreamID, ParentContext const &, typename T::Context const *)
Definition: Worker.h:1047
FilterAction filterAction_
Definition: WorkerInPath.h:63
void skipWorker(LuminosityBlockPrincipal const &)
Definition: WorkerInPath.h:42
PlaceInPathContext placeInPathContext_
Definition: WorkerInPath.h:66
void runWorkerAsync(WaitingTaskHolder, typename T::TransitionInfoType const &, ServiceToken const &, StreamID, typename T::Context const *)
Definition: WorkerInPath.h:107
void skipOnPath(EventPrincipal const &iEvent)
Definition: Worker.cc:385
int timesFailed() const
Definition: WorkerInPath.h:48
int timesPassed() const
Definition: WorkerInPath.h:47
long double T
bool runConcurrently() const noexcept
Definition: WorkerInPath.h:53