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(tbb::task::allocate_root(),
86  [&iSubProcesses, iWait, info = transitionInfo](std::exception_ptr const* iPtr) mutable {
87  if (iPtr) {
88  auto excpt = *iPtr;
89  auto delayError = make_waiting_task(
90  tbb::task::allocate_root(),
91  [iWait, excpt](std::exception_ptr const*) mutable { iWait.doneWaiting(excpt); });
92  WaitingTaskHolder h(delayError);
93  for (auto& subProcess : iSubProcesses) {
94  subProcessDoGlobalBeginTransitionAsync<Traits>(h, subProcess, info);
95  }
96  } else {
97  for (auto& subProcess : iSubProcesses) {
98  subProcessDoGlobalBeginTransitionAsync<Traits>(iWait, subProcess, info);
99  }
100  }
101  });
102 
103  WaitingTaskHolder h(subs);
104  iSchedule.processOneGlobalAsync<Traits>(std::move(h), transitionInfo, token);
105  }
106 
107  template <typename Traits>
109  Schedule& iSchedule,
110  typename Traits::TransitionInfoType& transitionInfo,
111  ServiceToken const& token,
112  std::vector<SubProcess>& iSubProcesses,
113  bool cleaningUpAfterException) {
114  // When we are done processing the global for this process,
115  // we need to run the global for all SubProcesses
116  auto subs =
117  make_waiting_task(tbb::task::allocate_root(),
118  [&iSubProcesses, iWait, info = transitionInfo, cleaningUpAfterException](
119  std::exception_ptr const* iPtr) mutable {
120  if (iPtr) {
121  auto excpt = *iPtr;
122  auto delayError = make_waiting_task(
123  tbb::task::allocate_root(),
124  [iWait, excpt](std::exception_ptr const*) mutable { iWait.doneWaiting(excpt); });
125  WaitingTaskHolder h(delayError);
126  for (auto& subProcess : iSubProcesses) {
127  subProcessDoGlobalEndTransitionAsync(h, subProcess, info, cleaningUpAfterException);
128  }
129  } else {
130  for (auto& subProcess : iSubProcesses) {
131  subProcessDoGlobalEndTransitionAsync(iWait, subProcess, info, cleaningUpAfterException);
132  }
133  }
134  });
135 
136  WaitingTaskHolder h(subs);
137  iSchedule.processOneGlobalAsync<Traits>(std::move(h), transitionInfo, token, cleaningUpAfterException);
138  }
139 
140 }; // namespace edm
141 
142 #endif
edm::Schedule::processOneGlobalAsync
void processOneGlobalAsync(WaitingTaskHolder iTask, typename T::TransitionInfoType &transitionInfo, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:330
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:442
edm::WaitingTaskHolder::doneWaiting
void doneWaiting(std::exception_ptr iExcept)
Definition: WaitingTaskHolder.h:75
edm::RunTransitionInfo
Definition: TransitionInfoTypes.h:64
edm::ServiceToken
Definition: ServiceToken.h:40
edm::Schedule
Definition: Schedule.h:121
h
edm::SubProcess::doBeginLuminosityBlockAsync
void doBeginLuminosityBlockAsync(WaitingTaskHolder iHolder, LumiTransitionInfo const &iTransitionInfo)
Definition: SubProcess.cc:563
edm::make_waiting_task
FunctorWaitingTask< F > * make_waiting_task(ALLOC &&iAlloc, F f)
Definition: WaitingTask.h:87
edm::beginGlobalTransitionAsync
void beginGlobalTransitionAsync(WaitingTaskHolder iWait, Schedule &iSchedule, typename Traits::TransitionInfoType &transitionInfo, ServiceToken const &token, std::vector< SubProcess > &iSubProcesses)
Definition: globalTransitionAsync.h:77
edm::WaitingTaskHolder
Definition: WaitingTaskHolder.h:30
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:485
edm::SubProcess::doBeginRunAsync
void doBeginRunAsync(WaitingTaskHolder iHolder, RunTransitionInfo const &iTransitionInfo)
Definition: SubProcess.cc:455
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:108
edm::subProcessDoGlobalEndTransitionAsync
void subProcessDoGlobalEndTransitionAsync(WaitingTaskHolder iHolder, SubProcess &iSubProcess, LumiTransitionInfo const &iTransitionInfo, bool cleaningUpAfterException)
Definition: globalTransitionAsync.h:55
edm::SubProcess::doEndLuminosityBlockAsync
void doEndLuminosityBlockAsync(WaitingTaskHolder iHolder, LumiTransitionInfo const &iTransitionInfo, bool cleaningUpAfterException)
Definition: SubProcess.cc:585
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:318