CMS 3D CMS Logo

streamTransitionAsync.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_streamTransitionAsync_h
2 #define FWCore_Framework_streamTransitionAsync_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Framework
6 // Function: streamTransitionAsync
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Tue, 06 Sep 2016 16:04:26 GMT
19 //
20 
26 
27 #include <vector>
28 
29 namespace edm {
30 
31  //This is code in common between beginStreamRun and beginStreamLuminosityBlock
33  SubProcess& iSubProcess,
34  unsigned int i,
35  LumiTransitionInfo const& iTransitionInfo) {
36  iSubProcess.doStreamBeginLuminosityBlockAsync(std::move(iHolder), i, iTransitionInfo);
37  }
38 
40  SubProcess& iSubProcess,
41  unsigned int i,
42  RunTransitionInfo const& iTransitionInfo) {
43  iSubProcess.doStreamBeginRunAsync(std::move(iHolder), i, iTransitionInfo);
44  }
45 
47  SubProcess& iSubProcess,
48  unsigned int i,
49  LumiTransitionInfo const& iTransitionInfo,
50  bool cleaningUpAfterException) {
51  iSubProcess.doStreamEndLuminosityBlockAsync(std::move(iHolder), i, iTransitionInfo, cleaningUpAfterException);
52  }
53 
55  SubProcess& iSubProcess,
56  unsigned int i,
57  RunTransitionInfo const& iTransitionInfo,
58  bool cleaningUpAfterException) {
59  iSubProcess.doStreamEndRunAsync(std::move(iHolder), i, iTransitionInfo, cleaningUpAfterException);
60  }
61 
62  template <typename Traits>
64  Schedule& iSchedule,
65  unsigned int iStreamIndex,
66  typename Traits::TransitionInfoType& transitionInfo,
67  ServiceToken const& token,
68  std::vector<SubProcess>& iSubProcesses) {
69  //When we are done processing the stream for this process,
70  // we need to run the stream for all SubProcesses
71  //NOTE: The subprocesses set their own service tokens
72  auto subs = make_waiting_task(
73  [&iSubProcesses, iWait, iStreamIndex, info = transitionInfo](std::exception_ptr const* iPtr) mutable {
74  if (iPtr) {
75  auto excpt = *iPtr;
76  auto delayError =
77  make_waiting_task([iWait, excpt](std::exception_ptr const*) mutable { iWait.doneWaiting(excpt); });
78  WaitingTaskHolder h(*iWait.group(), delayError);
79  for (auto& subProcess : iSubProcesses) {
80  subProcessDoStreamBeginTransitionAsync(h, subProcess, iStreamIndex, info);
81  };
82  } else {
83  for (auto& subProcess : iSubProcesses) {
84  subProcessDoStreamBeginTransitionAsync(iWait, subProcess, iStreamIndex, info);
85  };
86  }
87  });
88 
89  WaitingTaskHolder h(*iWait.group(), subs);
90  iSchedule.processOneStreamAsync<Traits>(std::move(h), iStreamIndex, transitionInfo, token);
91  }
92 
93  template <typename Traits>
95  Schedule& iSchedule,
96  unsigned int iNStreams,
97  typename Traits::TransitionInfoType& transitionInfo,
98  ServiceToken const& token,
99  std::vector<SubProcess>& iSubProcesses) {
100  for (unsigned int i = 0; i < iNStreams; ++i) {
101  beginStreamTransitionAsync<Traits>(iWait, iSchedule, i, transitionInfo, token, iSubProcesses);
102  }
103  }
104 
105  template <typename Traits>
107  Schedule& iSchedule,
108  unsigned int iStreamIndex,
109  typename Traits::TransitionInfoType& transitionInfo,
110  ServiceToken const& token,
111  std::vector<SubProcess>& iSubProcesses,
112  bool cleaningUpAfterException) {
113  //When we are done processing the stream for this process,
114  // we need to run the stream for all SubProcesses
115  //NOTE: The subprocesses set their own service tokens
116 
117  auto subs =
118  make_waiting_task([&iSubProcesses, iWait, iStreamIndex, info = transitionInfo, cleaningUpAfterException](
119  std::exception_ptr const* iPtr) mutable {
120  if (iPtr) {
121  auto excpt = *iPtr;
122  auto delayError =
123  make_waiting_task([iWait, excpt](std::exception_ptr const*) mutable { iWait.doneWaiting(excpt); });
124  WaitingTaskHolder h(*iWait.group(), delayError);
125  for (auto& subProcess : iSubProcesses) {
126  subProcessDoStreamEndTransitionAsync(h, subProcess, iStreamIndex, info, cleaningUpAfterException);
127  }
128  } else {
129  for (auto& subProcess : iSubProcesses) {
130  subProcessDoStreamEndTransitionAsync(iWait, subProcess, iStreamIndex, info, cleaningUpAfterException);
131  }
132  }
133  });
134 
135  iSchedule.processOneStreamAsync<Traits>(
136  WaitingTaskHolder(*iWait.group(), subs), iStreamIndex, transitionInfo, token, cleaningUpAfterException);
137  }
138 
139  template <typename Traits>
141  Schedule& iSchedule,
142  unsigned int iNStreams,
143  typename Traits::TransitionInfoType& transitionInfo,
144  ServiceToken const& iToken,
145  std::vector<SubProcess>& iSubProcesses,
146  bool cleaningUpAfterException) {
147  for (unsigned int i = 0; i < iNStreams; ++i) {
148  endStreamTransitionAsync<Traits>(
149  iWait, iSchedule, i, transitionInfo, iToken, iSubProcesses, cleaningUpAfterException);
150  }
151  }
152 }; // namespace edm
153 
154 #endif
mps_fire.i
i
Definition: mps_fire.py:428
edm::SubProcess
Definition: SubProcess.h:50
edm::subProcessDoStreamBeginTransitionAsync
void subProcessDoStreamBeginTransitionAsync(WaitingTaskHolder iHolder, SubProcess &iSubProcess, unsigned int i, LumiTransitionInfo const &iTransitionInfo)
Definition: streamTransitionAsync.h:32
edm::beginStreamTransitionAsync
void beginStreamTransitionAsync(WaitingTaskHolder iWait, Schedule &iSchedule, unsigned int iStreamIndex, typename Traits::TransitionInfoType &transitionInfo, ServiceToken const &token, std::vector< SubProcess > &iSubProcesses)
Definition: streamTransitionAsync.h:63
edm::LumiTransitionInfo
Definition: TransitionInfoTypes.h:42
edm::endStreamTransitionAsync
void endStreamTransitionAsync(WaitingTaskHolder iWait, Schedule &iSchedule, unsigned int iStreamIndex, typename Traits::TransitionInfoType &transitionInfo, ServiceToken const &token, std::vector< SubProcess > &iSubProcesses, bool cleaningUpAfterException)
Definition: streamTransitionAsync.h:106
WaitingTaskHolder.h
edm::SubProcess::doStreamEndRunAsync
void doStreamEndRunAsync(WaitingTaskHolder iHolder, unsigned int iID, RunTransitionInfo const &, bool cleaningUpAfterException)
Definition: SubProcess.cc:696
edm
HLT enums.
Definition: AlignableModifier.h:19
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
edm::WaitingTaskHolder::doneWaiting
void doneWaiting(std::exception_ptr iExcept)
Definition: WaitingTaskHolder.h:93
edm::Schedule::processOneStreamAsync
void processOneStreamAsync(WaitingTaskHolder iTask, unsigned int iStreamID, typename T::TransitionInfoType &transitionInfo, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:325
edm::RunTransitionInfo
Definition: TransitionInfoTypes.h:64
edm::ServiceToken
Definition: ServiceToken.h:42
edm::endStreamsTransitionAsync
void endStreamsTransitionAsync(WaitingTaskHolder iWait, Schedule &iSchedule, unsigned int iNStreams, typename Traits::TransitionInfoType &transitionInfo, ServiceToken const &iToken, std::vector< SubProcess > &iSubProcesses, bool cleaningUpAfterException)
Definition: streamTransitionAsync.h:140
edm::Schedule
Definition: Schedule.h:121
h
edm::make_waiting_task
FunctorWaitingTask< F > * make_waiting_task(F f)
Definition: WaitingTask.h:101
edm::WaitingTaskHolder
Definition: WaitingTaskHolder.h:32
edm::subProcessDoStreamEndTransitionAsync
void subProcessDoStreamEndTransitionAsync(WaitingTaskHolder iHolder, SubProcess &iSubProcess, unsigned int i, LumiTransitionInfo const &iTransitionInfo, bool cleaningUpAfterException)
Definition: streamTransitionAsync.h:46
Schedule.h
edm::SubProcess::doStreamBeginLuminosityBlockAsync
void doStreamBeginLuminosityBlockAsync(WaitingTaskHolder iHolder, unsigned int iID, LumiTransitionInfo const &)
Definition: SubProcess.cc:708
WaitingTask.h
SubProcess.h
edm::SubProcess::doStreamBeginRunAsync
void doStreamBeginRunAsync(WaitingTaskHolder iHolder, unsigned int iID, RunTransitionInfo const &)
Definition: SubProcess.cc:686
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::beginStreamsTransitionAsync
void beginStreamsTransitionAsync(WaitingTaskHolder iWait, Schedule &iSchedule, unsigned int iNStreams, typename Traits::TransitionInfoType &transitionInfo, ServiceToken const &token, std::vector< SubProcess > &iSubProcesses)
Definition: streamTransitionAsync.h:94
TransitionInfoTypes.h
edm::SubProcess::doStreamEndLuminosityBlockAsync
void doStreamEndLuminosityBlockAsync(WaitingTaskHolder iHolder, unsigned int iID, LumiTransitionInfo const &, bool cleaningUpAfterException)
Definition: SubProcess.cc:720
edm::WaitingTaskHolder::group
tbb::task_group * group() const noexcept
Definition: WaitingTaskHolder.h:77
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316