CMS 3D CMS Logo

globalTransitionAsync.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_globalTransitionAsync_h
2 #define FWCore_Framework_globalTransitionAsync_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Framework
6 // Function: globalTransitionAsync
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Tue, 06 Sep 2016 16:04:26 GMT
19 //
20 
26 
27 #include <exception>
28 #include <utility>
29 #include <vector>
30 
31 namespace edm {
32 
33  //This is code in common between beginStreamRun and beginGlobalLuminosityBlock
34  template <typename T>
36  SubProcess& iSubProcess,
37  LumiTransitionInfo const& iTransitionInfo) {
38  iSubProcess.doBeginLuminosityBlockAsync(std::move(iHolder), iTransitionInfo);
39  }
40 
41  template <typename T>
43  SubProcess& iSubProcess,
44  RunTransitionInfo const& iTransitionInfo) {
45  iSubProcess.doBeginRunAsync(std::move(iHolder), iTransitionInfo);
46  }
47 
48  template <typename Traits>
50  SubProcess& iSubProcess,
51  ProcessBlockTransitionInfo const& iTransitionInfo) {
52  iSubProcess.doBeginProcessBlockAsync<Traits>(std::move(iHolder), iTransitionInfo);
53  }
54 
56  SubProcess& iSubProcess,
57  LumiTransitionInfo const& iTransitionInfo,
58  bool cleaningUpAfterException) {
59  iSubProcess.doEndLuminosityBlockAsync(std::move(iHolder), iTransitionInfo, cleaningUpAfterException);
60  }
61 
63  SubProcess& iSubProcess,
64  RunTransitionInfo const& iTransitionInfo,
65  bool cleaningUpAfterException) {
66  iSubProcess.doEndRunAsync(std::move(iHolder), iTransitionInfo, cleaningUpAfterException);
67  }
68 
70  SubProcess& iSubProcess,
71  ProcessBlockTransitionInfo const& iTransitionInfo,
72  bool cleaningUpAfterException) {
73  iSubProcess.doEndProcessBlockAsync(std::move(iHolder), iTransitionInfo, cleaningUpAfterException);
74  }
75 
76  template <typename Traits>
78  Schedule& iSchedule,
79  typename Traits::TransitionInfoType& transitionInfo,
80  ServiceToken const& token,
81  std::vector<SubProcess>& iSubProcesses) {
82  // When we are done processing the global for this process,
83  // we need to run the global for all SubProcesses
84  auto subs =
85  make_waiting_task([&iSubProcesses, iWait, info = transitionInfo](std::exception_ptr const* iPtr) mutable {
86  if (iPtr) {
87  auto excpt = *iPtr;
88  auto delayError =
89  make_waiting_task([iWait, excpt](std::exception_ptr const*) mutable { iWait.doneWaiting(excpt); });
90  WaitingTaskHolder h(*iWait.group(), delayError);
91  for (auto& subProcess : iSubProcesses) {
92  subProcessDoGlobalBeginTransitionAsync<Traits>(h, subProcess, info);
93  }
94  } else {
95  for (auto& subProcess : iSubProcesses) {
96  subProcessDoGlobalBeginTransitionAsync<Traits>(iWait, subProcess, info);
97  }
98  }
99  });
100 
101  WaitingTaskHolder h(*iWait.group(), subs);
102  iSchedule.processOneGlobalAsync<Traits>(std::move(h), transitionInfo, token);
103  }
104 
105  template <typename Traits>
107  Schedule& iSchedule,
108  typename Traits::TransitionInfoType& transitionInfo,
109  ServiceToken const& token,
110  std::vector<SubProcess>& iSubProcesses,
111  bool cleaningUpAfterException) {
112  // When we are done processing the global for this process,
113  // we need to run the global for all SubProcesses
114  auto subs = make_waiting_task([&iSubProcesses, iWait, info = transitionInfo, cleaningUpAfterException](
115  std::exception_ptr const* iPtr) mutable {
116  if (iPtr) {
117  auto excpt = *iPtr;
118  auto delayError =
119  make_waiting_task([iWait, excpt](std::exception_ptr const*) mutable { iWait.doneWaiting(excpt); });
120  WaitingTaskHolder h(*iWait.group(), delayError);
121  for (auto& subProcess : iSubProcesses) {
122  subProcessDoGlobalEndTransitionAsync(h, subProcess, info, cleaningUpAfterException);
123  }
124  } else {
125  for (auto& subProcess : iSubProcesses) {
126  subProcessDoGlobalEndTransitionAsync(iWait, subProcess, info, cleaningUpAfterException);
127  }
128  }
129  });
130 
131  WaitingTaskHolder h(*iWait.group(), subs);
132  iSchedule.processOneGlobalAsync<Traits>(std::move(h), transitionInfo, token, cleaningUpAfterException);
133  }
134 
135 }; // namespace edm
136 
137 #endif
edm::Schedule::processOneGlobalAsync
void processOneGlobalAsync(WaitingTaskHolder iTask, typename T::TransitionInfoType &transitionInfo, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:336
edm::ProcessBlockTransitionInfo
Definition: TransitionInfoTypes.h:80
edm::SubProcess
Definition: SubProcess.h:50
edm::LumiTransitionInfo
Definition: TransitionInfoTypes.h:42
WaitingTaskHolder.h
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::SubProcess::doEndProcessBlockAsync
void doEndProcessBlockAsync(WaitingTaskHolder iHolder, ProcessBlockTransitionInfo const &iTransitionInfo, bool cleaningUpAfterException)
Definition: SubProcess.cc:493
edm::WaitingTaskHolder::doneWaiting
void doneWaiting(std::exception_ptr iExcept)
Definition: WaitingTaskHolder.h:93
edm::RunTransitionInfo
Definition: TransitionInfoTypes.h:64
edm::ServiceToken
Definition: ServiceToken.h:42
edm::Schedule
Definition: Schedule.h:121
h
edm::SubProcess::doBeginLuminosityBlockAsync
void doBeginLuminosityBlockAsync(WaitingTaskHolder iHolder, LumiTransitionInfo const &iTransitionInfo)
Definition: SubProcess.cc:612
edm::beginGlobalTransitionAsync
void beginGlobalTransitionAsync(WaitingTaskHolder iWait, Schedule &iSchedule, typename Traits::TransitionInfoType &transitionInfo, ServiceToken const &token, std::vector< SubProcess > &iSubProcesses)
Definition: globalTransitionAsync.h:77
edm::make_waiting_task
FunctorWaitingTask< F > * make_waiting_task(F f)
Definition: WaitingTask.h:101
edm::WaitingTaskHolder
Definition: WaitingTaskHolder.h:32
edm::subProcessDoGlobalBeginTransitionAsync
void subProcessDoGlobalBeginTransitionAsync(WaitingTaskHolder iHolder, SubProcess &iSubProcess, LumiTransitionInfo const &iTransitionInfo)
Definition: globalTransitionAsync.h:35
edm::SubProcess::doBeginProcessBlockAsync
void doBeginProcessBlockAsync(WaitingTaskHolder iHolder, ProcessBlockTransitionInfo const &iTransitionInfo)
Schedule.h
WaitingTask.h
SubProcess.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::SubProcess::doEndRunAsync
void doEndRunAsync(WaitingTaskHolder iHolder, RunTransitionInfo const &iTransitionInfo, bool cleaningUpAfterException)
Definition: SubProcess.cc:536
edm::SubProcess::doBeginRunAsync
void doBeginRunAsync(WaitingTaskHolder iHolder, RunTransitionInfo const &iTransitionInfo)
Definition: SubProcess.cc:506
TransitionInfoTypes.h
edm::endGlobalTransitionAsync
void endGlobalTransitionAsync(WaitingTaskHolder iWait, Schedule &iSchedule, typename Traits::TransitionInfoType &transitionInfo, ServiceToken const &token, std::vector< SubProcess > &iSubProcesses, bool cleaningUpAfterException)
Definition: globalTransitionAsync.h:106
edm::subProcessDoGlobalEndTransitionAsync
void subProcessDoGlobalEndTransitionAsync(WaitingTaskHolder iHolder, SubProcess &iSubProcess, LumiTransitionInfo const &iTransitionInfo, bool cleaningUpAfterException)
Definition: globalTransitionAsync.h:55
edm::WaitingTaskHolder::group
tbb::task_group * group() const noexcept
Definition: WaitingTaskHolder.h:77
edm::SubProcess::doEndLuminosityBlockAsync
void doEndLuminosityBlockAsync(WaitingTaskHolder iHolder, LumiTransitionInfo const &iTransitionInfo, bool cleaningUpAfterException)
Definition: SubProcess.cc:634
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316