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  bool) {
39  iSubProcess.doBeginLuminosityBlockAsync(std::move(iHolder), iTransitionInfo);
40  }
41 
42  template <typename T>
44  SubProcess& iSubProcess,
45  RunTransitionInfo const& iTransitionInfo,
46  bool) {
47  iSubProcess.doBeginRunAsync(std::move(iHolder), iTransitionInfo);
48  }
49 
50  template <typename Traits>
52  SubProcess& iSubProcess,
53  ProcessBlockTransitionInfo const& iTransitionInfo,
54  bool cleaningUpAfterException) {
55  iSubProcess.doBeginProcessBlockAsync<Traits>(std::move(iHolder), iTransitionInfo, cleaningUpAfterException);
56  }
57 
59  SubProcess& iSubProcess,
60  LumiTransitionInfo const& iTransitionInfo,
61  bool cleaningUpAfterException) {
62  iSubProcess.doEndLuminosityBlockAsync(std::move(iHolder), iTransitionInfo, cleaningUpAfterException);
63  }
64 
66  SubProcess& iSubProcess,
67  RunTransitionInfo const& iTransitionInfo,
68  bool cleaningUpAfterException) {
69  iSubProcess.doEndRunAsync(std::move(iHolder), iTransitionInfo, cleaningUpAfterException);
70  }
71 
73  SubProcess& iSubProcess,
74  ProcessBlockTransitionInfo const& iTransitionInfo,
75  bool cleaningUpAfterException) {
76  iSubProcess.doEndProcessBlockAsync(std::move(iHolder), iTransitionInfo, cleaningUpAfterException);
77  }
78 
79  template <typename Traits>
81  Schedule& iSchedule,
82  typename Traits::TransitionInfoType& transitionInfo,
83  ServiceToken const& token,
84  std::vector<SubProcess>& iSubProcesses,
85  bool cleaningUpAfterException = false) {
86  // When we are done processing the global for this process,
87  // we need to run the global for all SubProcesses
88  auto subs = make_waiting_task([&iSubProcesses, iWait, info = transitionInfo, cleaningUpAfterException](
89  std::exception_ptr const* iPtr) mutable {
90  if (iPtr) {
91  auto excpt = *iPtr;
92  auto delayError =
93  make_waiting_task([iWait, excpt](std::exception_ptr const*) mutable { iWait.doneWaiting(excpt); });
94  WaitingTaskHolder h(*iWait.group(), delayError);
95  for (auto& subProcess : iSubProcesses) {
96  subProcessDoGlobalBeginTransitionAsync<Traits>(h, subProcess, info, cleaningUpAfterException);
97  }
98  } else {
99  for (auto& subProcess : iSubProcesses) {
100  subProcessDoGlobalBeginTransitionAsync<Traits>(iWait, subProcess, info, cleaningUpAfterException);
101  }
102  }
103  });
104 
105  WaitingTaskHolder h(*iWait.group(), subs);
106  iSchedule.processOneGlobalAsync<Traits>(std::move(h), transitionInfo, token, cleaningUpAfterException);
107  }
108 
109  template <typename Traits>
111  Schedule& iSchedule,
112  typename Traits::TransitionInfoType& transitionInfo,
113  ServiceToken const& token,
114  std::vector<SubProcess>& iSubProcesses,
115  bool cleaningUpAfterException) {
116  // When we are done processing the global for this process,
117  // we need to run the global for all SubProcesses
118  auto subs = make_waiting_task([&iSubProcesses, iWait, 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  subProcessDoGlobalEndTransitionAsync(h, subProcess, info, cleaningUpAfterException);
127  }
128  } else {
129  for (auto& subProcess : iSubProcesses) {
130  subProcessDoGlobalEndTransitionAsync(iWait, subProcess, info, cleaningUpAfterException);
131  }
132  }
133  });
134 
135  WaitingTaskHolder h(*iWait.group(), subs);
136  iSchedule.processOneGlobalAsync<Traits>(std::move(h), transitionInfo, token, cleaningUpAfterException);
137  }
138 
139 }; // namespace edm
140 
141 #endif
edm::Schedule::processOneGlobalAsync
void processOneGlobalAsync(WaitingTaskHolder iTask, typename T::TransitionInfoType &transitionInfo, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:338
edm::ProcessBlockTransitionInfo
Definition: TransitionInfoTypes.h:80
edm::SubProcess
Definition: SubProcess.h:52
edm::subProcessDoGlobalBeginTransitionAsync
void subProcessDoGlobalBeginTransitionAsync(WaitingTaskHolder iHolder, SubProcess &iSubProcess, LumiTransitionInfo const &iTransitionInfo, bool)
Definition: globalTransitionAsync.h:35
edm::LumiTransitionInfo
Definition: TransitionInfoTypes.h:42
WaitingTaskHolder.h
edm
HLT enums.
Definition: AlignableModifier.h:19
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
edm::SubProcess::doBeginProcessBlockAsync
void doBeginProcessBlockAsync(WaitingTaskHolder iHolder, ProcessBlockTransitionInfo const &iTransitionInfo, bool cleaningUpAfterException)
edm::SubProcess::doEndProcessBlockAsync
void doEndProcessBlockAsync(WaitingTaskHolder iHolder, ProcessBlockTransitionInfo const &iTransitionInfo, bool cleaningUpAfterException)
Definition: SubProcess.cc:503
edm::WaitingTaskHolder::doneWaiting
void doneWaiting(std::exception_ptr iExcept)
Definition: WaitingTaskHolder.h:93
h
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
edm::RunTransitionInfo
Definition: TransitionInfoTypes.h:64
edm::ServiceToken
Definition: ServiceToken.h:42
edm::Schedule
Definition: Schedule.h:122
h
edm::SubProcess::doBeginLuminosityBlockAsync
void doBeginLuminosityBlockAsync(WaitingTaskHolder iHolder, LumiTransitionInfo const &iTransitionInfo)
Definition: SubProcess.cc:668
edm::make_waiting_task
FunctorWaitingTask< F > * make_waiting_task(F f)
Definition: WaitingTask.h:101
edm::WaitingTaskHolder
Definition: WaitingTaskHolder.h:32
Schedule.h
edm::beginGlobalTransitionAsync
void beginGlobalTransitionAsync(WaitingTaskHolder iWait, Schedule &iSchedule, typename Traits::TransitionInfoType &transitionInfo, ServiceToken const &token, std::vector< SubProcess > &iSubProcesses, bool cleaningUpAfterException=false)
Definition: globalTransitionAsync.h:80
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:592
edm::SubProcess::doBeginRunAsync
void doBeginRunAsync(WaitingTaskHolder iHolder, RunTransitionInfo const &iTransitionInfo)
Definition: SubProcess.cc:562
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:110
edm::subProcessDoGlobalEndTransitionAsync
void subProcessDoGlobalEndTransitionAsync(WaitingTaskHolder iHolder, SubProcess &iSubProcess, LumiTransitionInfo const &iTransitionInfo, bool cleaningUpAfterException)
Definition: globalTransitionAsync.h:58
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:690
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316