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 #include <utility>
20 
21 namespace edm {
22 
23  class PathContext;
24  class StreamID;
25  class ServiceToken;
26 
27  class WorkerInPath {
28  public:
29  enum FilterAction { Normal = 0, Ignore, Veto };
30 
31  WorkerInPath(Worker*, FilterAction theAction, unsigned int placeInPath, bool runConcurrently);
32 
33  template <typename T>
35  typename T::TransitionInfoType const&,
36  ServiceToken const&,
37  StreamID,
38  typename T::Context const*) noexcept;
39 
40  bool checkResultsOfRunWorker(bool wasEvent);
41 
42  void skipWorker(EventPrincipal const& iPrincipal) { worker_->skipOnPath(iPrincipal); }
43  void skipWorker(RunPrincipal const&) {}
45 
47 
48  int timesVisited() const { return timesVisited_; }
49  int timesPassed() const { return timesPassed_; }
50  int timesFailed() const { return timesFailed_; }
51  int timesExcept() const { return timesExcept_; }
52 
54  Worker* getWorker() const { return worker_; }
55  bool runConcurrently() const noexcept { return runConcurrently_; }
56  unsigned int bitPosition() const noexcept { return placeInPathContext_.placeInPath(); }
57 
59 
60  private:
65 
68 
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  rc = false;
82  break;
83  }
84  case Worker::Pass:
85  break;
86  case Worker::Exception: {
87  ++timesExcept_;
88  return true;
89  }
90 
91  default:
92  assert(false);
93  }
94 
95  if (Ignore == filterAction()) {
96  rc = true;
97  } else if (Veto == filterAction()) {
98  rc = !rc;
99  }
100 
101  if (rc) {
102  ++timesPassed_;
103  } else {
104  ++timesFailed_;
105  }
106  return rc;
107  }
108 
109  template <typename T>
111  typename T::TransitionInfoType const& info,
112  ServiceToken const& token,
113  StreamID streamID,
114  typename T::Context const* context) noexcept {
115  static_assert(T::isEvent_);
116 
117  ++timesVisited_;
118  ParentContext parentContext(&placeInPathContext_);
119  worker_->doWorkAsync<T>(std::move(iTask), info, token, streamID, parentContext, context);
120  }
121 } // namespace edm
122 
123 #endif
void runWorkerAsync(WaitingTaskHolder, typename T::TransitionInfoType const &, ServiceToken const &, StreamID, typename T::Context const *) noexcept
Definition: WorkerInPath.h:110
static const TGPicture * info(bool iBackgroundIsBlack)
void setPathContext(PathContext const *v)
bool checkResultsOfRunWorker(bool wasEvent)
Definition: WorkerInPath.h:73
FilterAction filterAction() const
Definition: WorkerInPath.h:53
int timesExcept() const
Definition: WorkerInPath.h:51
void skipWorker(EventPrincipal const &iPrincipal)
Definition: WorkerInPath.h:42
assert(be >=bs)
int timesPassed() const
Definition: WorkerInPath.h:49
void setPathContext(PathContext const *v)
Definition: WorkerInPath.h:58
WorkerInPath(Worker *, FilterAction theAction, unsigned int placeInPath, bool runConcurrently)
Definition: WorkerInPath.cc:6
void skipWorker(RunPrincipal const &)
Definition: WorkerInPath.h:43
unsigned int bitPosition() const noexcept
Definition: WorkerInPath.h:56
FilterAction filterAction_
Definition: WorkerInPath.h:66
unsigned int placeInPath() const
void skipWorker(LuminosityBlockPrincipal const &)
Definition: WorkerInPath.h:44
PlaceInPathContext placeInPathContext_
Definition: WorkerInPath.h:69
void skipOnPath(EventPrincipal const &iEvent)
Definition: Worker.cc:381
Worker * getWorker() const
Definition: WorkerInPath.h:54
int timesVisited() const
Definition: WorkerInPath.h:48
HLT enums.
int timesFailed() const
Definition: WorkerInPath.h:50
long double T
State state() const noexcept
Definition: Worker.h:249
def move(src, dest)
Definition: eostools.py:511
bool runConcurrently() const noexcept
Definition: WorkerInPath.h:55