Schedule.h
Go to the documentation of this file.
1 #ifndef art_Framework_Core_Schedule_h
2 #define art_Framework_Core_Schedule_h
3 // vim: set sw=2 expandtab :
4 
5 // ======================================================================
6 // Schedule
7 //
8 // A schedule contains all trigger paths and the end path executor for
9 // a stream of events.
10 //
11 // Processing of an event happens by pushing the event through the
12 // Paths. The scheduler performs the reset() on each of the workers
13 // independent of the Path objects.
14 // ======================================================================
15 
20 
21 #include <atomic>
22 #include <cassert>
23 #include <memory>
24 #include <utility>
25 
26 namespace art {
27  class ActivityRegistry;
28  namespace detail {
29  class SharedResources;
30  }
31 
32  class Schedule {
33  public:
34  Schedule(ScheduleID sid,
35  PathManager& pm,
36  ActionTable const& actions,
37  ActivityRegistry const& aReg,
38  UpdateOutputCallbacks& outputCallbacks,
39  std::unique_ptr<Worker> triggerResultsInserter,
40  GlobalTaskGroup& task_group);
41 
42  // Disable copy/move operations
43  Schedule(Schedule const&) = delete;
44  Schedule(Schedule&&) = delete;
45  Schedule& operator=(Schedule const&) = delete;
46  Schedule& operator=(Schedule&&) = delete;
47 
48  // API presented to EventProcessor
50  void process_event_modifiers(hep::concurrency::WaitingTaskPtr endPathTask);
51  void process_event_observers(
52  hep::concurrency::WaitingTaskPtr finalizeEventTask);
53  void beginJob(detail::SharedResources const& resources);
54  void endJob();
55  void respondToOpenInputFile(FileBlock const&);
56  void respondToCloseInputFile(FileBlock const&);
57  void respondToOpenOutputFiles(FileBlock const&);
58  void respondToCloseOutputFiles(FileBlock const&);
59 
60  // End-path API
61  bool
62  outputsToOpen() const
63  {
64  return epExec_.outputsToOpen();
65  }
66 
67  bool
69  {
70  return epExec_.outputsToClose();
71  }
72 
73  void
75  {
76  return epExec_.recordOutputClosureRequests(granularity);
77  }
78 
79  bool
81  {
82  return epExec_.someOutputsOpen();
83  }
84 
85  void
87  {
88  epExec_.closeAllOutputFiles();
89  }
90 
91  void
93  {
94  epExec_.openSomeOutputFiles(fb);
95  }
96 
97  void
99  {
100  epExec_.closeSomeOutputFiles();
101  }
102 
103  void
105  {
106  assert(eventPrincipal_);
107  epExec_.writeEvent(*eventPrincipal_);
108  // Delete principal
109  eventPrincipal_.reset();
110  }
111 
112  void
114  {
115  epExec_.incrementInputFileNumber();
116  }
117 
118  void
120  {
121  epExec_.setOutputFileStatus(ofs);
122  }
123 
125  fileStatus() const
126  {
127  return epExec_.fileStatus_.load();
128  }
129 
130  bool
131  allAtLimit() const
132  {
133  return epExec_.allAtLimit();
134  }
135 
136  // Run level
137  void
139  {
140  epExec_.seedRunRangeSet(rsh);
141  }
142 
143  void
145  {
146  epExec_.setRunAuxiliaryRangeSetID(rs);
147  }
148 
149  void
151  {
152  epExec_.writeRun(rp);
153  }
154 
155  RangeSetHandler const&
157  {
158  return *epExec_.runRangeSetHandler_.get();
159  }
160 
161  // SubRun level
162  void
164  {
165  epExec_.seedSubRunRangeSet(rsh);
166  }
167  void
169  {
170  epExec_.setSubRunAuxiliaryRangeSetID(rs);
171  }
172  void
174  {
175  epExec_.writeSubRun(srp);
176  }
177 
178  RangeSetHandler const&
180  {
181  return *epExec_.subRunRangeSetHandler_.get();
182  }
183 
184  void
185  accept_principal(std::unique_ptr<EventPrincipal> principal)
186  {
187  assert(principal);
188  eventPrincipal_ = std::move(principal);
189  }
190 
193  {
194  assert(eventPrincipal_);
195  return *eventPrincipal_;
196  }
197 
198  class EndPathRunnerTask;
199 
200  private:
206  std::unique_ptr<EventPrincipal> eventPrincipal_{nullptr};
207  };
208 } // namespace art
209 
210 // Local Variables:
211 // mode: c++
212 // End:
213 
214 #endif /* art_Framework_Core_Schedule_h */
void closeAllOutputFiles()
Definition: Schedule.h:86
void setSubRunAuxiliaryRangeSetID(RangeSet const &rs)
Definition: Schedule.h:168
RangeSetHandler const & runRangeSetHandler()
Definition: Schedule.h:156
EndPathExecutor epExec_
Definition: Schedule.h:204
ActivityRegistry const & actReg_
Definition: Schedule.h:203
bool outputsToClose() const
Definition: Schedule.h:68
void seedSubRunRangeSet(RangeSetHandler const &rsh)
Definition: Schedule.h:163
ScheduleContext const context_
Definition: Schedule.h:198
void setRunAuxiliaryRangeSetID(RangeSet const &rs)
Definition: Schedule.h:144
def process(f, kind)
Definition: search.py:254
TriggerPathsExecutor tpsExec_
Definition: Schedule.h:205
bool allAtLimit() const
Definition: Schedule.h:131
OutputFileStatus
EventPrincipal & event_principal()
Definition: Schedule.h:192
Transition
Definition: Transition.h:7
void beginJob()
Definition: Breakpoints.cc:14
def move(depos, offset)
Definition: depos.py:107
void writeEvent()
Definition: Schedule.h:104
RangeSetHandler const & subRunRangeSetHandler()
Definition: Schedule.h:179
void recordOutputClosureRequests(Granularity const granularity)
Definition: Schedule.h:74
OutputFileStatus fileStatus() const
Definition: Schedule.h:125
void incrementInputFileNumber()
Definition: Schedule.h:113
bool outputsToOpen() const
Definition: Schedule.h:62
ActionTable const & actions_
Definition: Schedule.h:202
void closeSomeOutputFiles()
Definition: Schedule.h:98
void accept_principal(std::unique_ptr< EventPrincipal > principal)
Definition: Schedule.h:185
Namespace containing all the test actions.
void seedRunRangeSet(RangeSetHandler const &rsh)
Definition: Schedule.h:138
void writeRun(RunPrincipal &rp)
Definition: Schedule.h:150
void openSomeOutputFiles(FileBlock const &fb)
Definition: Schedule.h:92
void writeSubRun(SubRunPrincipal &srp)
Definition: Schedule.h:173
void setOutputFileStatus(OutputFileStatus const ofs)
Definition: Schedule.h:119
bool someOutputsOpen() const
Definition: Schedule.h:80