WorkerInPath.h
Go to the documentation of this file.
1 #ifndef art_Framework_Core_WorkerInPath_h
2 #define art_Framework_Core_WorkerInPath_h
3 // vim: set sw=2 expandtab :
4 
5 // ====================================================================
6 // The WorkerInPath is a wrapper around a Worker, so that statistics
7 // can be managed per path. A Path holds Workers as these things.
8 //
9 // For a given module label, there will be n*m WorkerInPath objects,
10 // where n is the number of configured schedules, and m is the number
11 // paths in which the module label appears.
12 // ====================================================================
13 
19 #include "cetlib/exempt_ptr.h"
20 #include "hep_concurrency/WaitingTask.h"
21 
22 #include <atomic>
23 #include <memory>
24 #include <string>
25 #include <utility>
26 #include <vector>
27 
28 namespace art {
30 
31  namespace detail {
32  struct ModuleConfigInfo;
33  }
34 
35  class PathContext;
36 
37  class WorkerInPath {
38  public:
39  enum FilterAction { Normal = 0, Ignore = 1, Veto = 2 };
40  struct ConfigInfo {
42  FilterAction const action)
43  : moduleConfigInfo{info}, filterAction{action}
44  {}
47  };
48 
49  // Special Member Functions
50  ~WorkerInPath() noexcept;
52  WorkerInPath(WorkerInPath const&) = delete;
54  WorkerInPath& operator=(WorkerInPath const&) = delete;
55  WorkerInPath& operator=(WorkerInPath&&);
56 
57  // API for user
58  Worker* getWorker() const;
59  FilterAction filterAction() const;
60 
61  // Used only by Path
62  bool returnCode() const;
63  std::string const& label() const;
64  bool runWorker(Transition, Principal&);
65  void runWorker_event_for_endpath(EventPrincipal&);
66  void runWorker_event(hep::concurrency::WaitingTask* workerDoneTask,
67  EventPrincipal&);
68  // Used only by Path
69  void clearCounters();
70 
71  // Used by writeSummary
72  std::size_t timesVisited() const;
73  std::size_t timesPassed() const;
74  std::size_t timesFailed() const;
75  std::size_t timesExcept() const;
76 
77  // Task Structure
78  void workerInPathDoneTask(ScheduleID const, std::exception_ptr const*);
79 
80  private:
81  std::atomic<Worker*> worker_;
82  std::atomic<FilterAction> filterAction_;
83  ModuleContext moduleContext_;
84 
85  // Per-schedule
86  std::atomic<bool> returnCode_;
87  std::atomic<hep::concurrency::WaitingTaskList*> waitingTasks_;
88 
89  // Counts
90  std::atomic<std::size_t> counts_visited_;
91  std::atomic<std::size_t> counts_passed_;
92  std::atomic<std::size_t> counts_failed_;
93  std::atomic<std::size_t> counts_thrown_;
94  };
95 
96 } // namespace art
97 
98 #endif /* art_Framework_Core_WorkerInPath_h */
99 
100 // Local Variables:
101 // mode: c++
102 // End:
ConfigInfo(cet::exempt_ptr< detail::ModuleConfigInfo const > const info, FilterAction const action)
Definition: WorkerInPath.h:41
const XML_Char XML_Encoding * info
Definition: expat.h:530
std::string module_label_t
Definition: WorkerInPath.h:29
const char * label
Transition
Definition: Transition.h:7
cet::exempt_ptr< detail::ModuleConfigInfo const > moduleConfigInfo
Definition: WorkerInPath.h:45
Service to store calibration data products (CDP) in the SQLite3 metadatabase of a file...
Definition: FillParentInfo.h:8
enum BeamMode string