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 
21 // system include files
27 
28 #include <memory>
29 #include <vector>
30 
31 // user include files
32 
33 // forward declarations
34 
35 namespace edm {
36  class EventSetupImpl;
37  class LuminosityBlockPrincipal;
38  class RunPrincipal;
39 
40  //This is code in common between beginStreamRun and beginGlobalLuminosityBlock
42  WaitingTaskHolder iHolder,
43  SubProcess& iSubProcess,
44  LuminosityBlockPrincipal& iPrincipal,
45  IOVSyncValue const& iTS,
46  std::vector<std::shared_ptr<const EventSetupImpl>> const* iEventSetupImpls) {
47  iSubProcess.doBeginLuminosityBlockAsync(std::move(iHolder), iPrincipal, iTS, iEventSetupImpls);
48  }
49 
51  WaitingTaskHolder iHolder,
52  SubProcess& iSubProcess,
53  RunPrincipal& iPrincipal,
54  IOVSyncValue const& iTS,
55  std::vector<std::shared_ptr<const EventSetupImpl>> const* iEventSetupImpls) {
56  iSubProcess.doBeginRunAsync(std::move(iHolder), iPrincipal, iTS, iEventSetupImpls);
57  }
58 
60  WaitingTaskHolder iHolder,
61  SubProcess& iSubProcess,
62  LuminosityBlockPrincipal& iPrincipal,
63  IOVSyncValue const& iTS,
64  std::vector<std::shared_ptr<const EventSetupImpl>> const* iEventSetupImpls,
65  bool cleaningUpAfterException) {
66  iSubProcess.doEndLuminosityBlockAsync(
67  std::move(iHolder), iPrincipal, iTS, iEventSetupImpls, cleaningUpAfterException);
68  }
69 
71  WaitingTaskHolder iHolder,
72  SubProcess& iSubProcess,
73  RunPrincipal& iPrincipal,
74  IOVSyncValue const& iTS,
75  std::vector<std::shared_ptr<const EventSetupImpl>> const* iEventSetupImpls,
76  bool cleaningUpAfterException) {
77  iSubProcess.doEndRunAsync(std::move(iHolder), iPrincipal, iTS, iEventSetupImpls, cleaningUpAfterException);
78  }
79 
80  template <typename Traits, typename P, typename SC>
82  WaitingTaskHolder iWait,
83  Schedule& iSchedule,
84  P& iPrincipal,
85  IOVSyncValue const& iTS,
86  EventSetupImpl const& iES,
87  std::vector<std::shared_ptr<const EventSetupImpl>> const*
88  iEventSetupImpls, // always null for runs until we enable concurrent run processing
89  ServiceToken const& token,
90  SC& iSubProcesses) {
91  //When we are done processing the global for this process,
92  // we need to run the global for all SubProcesses
93  auto subs = make_waiting_task(
94  tbb::task::allocate_root(),
95  [&iSubProcesses, iWait, &iPrincipal, iTS, iEventSetupImpls](std::exception_ptr const* iPtr) mutable {
96  if (iPtr) {
97  auto excpt = *iPtr;
98  auto delayError =
99  make_waiting_task(tbb::task::allocate_root(),
100  [iWait, excpt](std::exception_ptr const*) mutable { iWait.doneWaiting(excpt); });
101  WaitingTaskHolder h(delayError);
102  for (auto& subProcess : iSubProcesses) {
103  subProcessDoGlobalBeginTransitionAsync(h, subProcess, iPrincipal, iTS, iEventSetupImpls);
104  }
105  } else {
106  for (auto& subProcess : iSubProcesses) {
107  subProcessDoGlobalBeginTransitionAsync(iWait, subProcess, iPrincipal, iTS, iEventSetupImpls);
108  }
109  }
110  });
111 
112  WaitingTaskHolder h(subs);
113  iSchedule.processOneGlobalAsync<Traits>(std::move(h), iPrincipal, iES, token);
114  }
115 
116  template <typename Traits, typename P, typename SC>
118  Schedule& iSchedule,
119  P& iPrincipal,
120  IOVSyncValue const& iTS,
121  EventSetupImpl const& iES,
122  std::vector<std::shared_ptr<const EventSetupImpl>> const*
123  iEventSetupImpls, // always null for runs until we enable concurrent run processing
124  ServiceToken const& token,
125  SC& iSubProcesses,
126  bool cleaningUpAfterException) {
127  //When we are done processing the global for this process,
128  // we need to run the global for all SubProcesses
129  auto subs =
130  make_waiting_task(tbb::task::allocate_root(),
131  [&iSubProcesses, iWait, &iPrincipal, iTS, iEventSetupImpls, cleaningUpAfterException](
132  std::exception_ptr const* iPtr) mutable {
133  if (iPtr) {
134  auto excpt = *iPtr;
135  auto delayError = make_waiting_task(
136  tbb::task::allocate_root(),
137  [iWait, excpt](std::exception_ptr const*) mutable { iWait.doneWaiting(excpt); });
138  WaitingTaskHolder h(delayError);
139  for (auto& subProcess : iSubProcesses) {
141  h, subProcess, iPrincipal, iTS, iEventSetupImpls, cleaningUpAfterException);
142  }
143  } else {
144  for (auto& subProcess : iSubProcesses) {
146  iWait, subProcess, iPrincipal, iTS, iEventSetupImpls, cleaningUpAfterException);
147  }
148  }
149  });
150 
151  WaitingTaskHolder h(subs);
152  iSchedule.processOneGlobalAsync<Traits>(std::move(h), iPrincipal, iES, token, cleaningUpAfterException);
153  }
154 
155 }; // namespace edm
156 
157 #endif
edm::endGlobalTransitionAsync
void endGlobalTransitionAsync(WaitingTaskHolder iWait, Schedule &iSchedule, P &iPrincipal, IOVSyncValue const &iTS, EventSetupImpl const &iES, std::vector< std::shared_ptr< const EventSetupImpl >> const *iEventSetupImpls, ServiceToken const &token, SC &iSubProcesses, bool cleaningUpAfterException)
Definition: globalTransitionAsync.h:117
edm::SubProcess
Definition: SubProcess.h:46
edm::EventSetupImpl
Definition: EventSetupImpl.h:44
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
edm::LuminosityBlockPrincipal
Definition: LuminosityBlockPrincipal.h:31
edm::subProcessDoGlobalEndTransitionAsync
void subProcessDoGlobalEndTransitionAsync(WaitingTaskHolder iHolder, SubProcess &iSubProcess, LuminosityBlockPrincipal &iPrincipal, IOVSyncValue const &iTS, std::vector< std::shared_ptr< const EventSetupImpl >> const *iEventSetupImpls, bool cleaningUpAfterException)
Definition: globalTransitionAsync.h:59
edm::WaitingTaskHolder::doneWaiting
void doneWaiting(std::exception_ptr iExcept)
Definition: WaitingTaskHolder.h:75
edm::ServiceToken
Definition: ServiceToken.h:40
edm::Schedule
Definition: Schedule.h:122
edm::subProcessDoGlobalBeginTransitionAsync
void subProcessDoGlobalBeginTransitionAsync(WaitingTaskHolder iHolder, SubProcess &iSubProcess, LuminosityBlockPrincipal &iPrincipal, IOVSyncValue const &iTS, std::vector< std::shared_ptr< const EventSetupImpl >> const *iEventSetupImpls)
Definition: globalTransitionAsync.h:41
h
edm::SubProcess::doBeginRunAsync
void doBeginRunAsync(WaitingTaskHolder iHolder, RunPrincipal const &principal, IOVSyncValue const &ts, std::vector< std::shared_ptr< const EventSetupImpl >> const *)
Definition: SubProcess.cc:406
edm::make_waiting_task
FunctorWaitingTask< F > * make_waiting_task(ALLOC &&iAlloc, F f)
Definition: WaitingTask.h:87
edm::IOVSyncValue
Definition: IOVSyncValue.h:31
edm::WaitingTaskHolder
Definition: WaitingTaskHolder.h:30
Schedule.h
edm::Schedule::processOneGlobalAsync
void processOneGlobalAsync(WaitingTaskHolder iTask, typename T::MyPrincipal &principal, EventSetupImpl const &eventSetup, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:330
WaitingTask.h
SubProcess.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::SubProcess::doEndRunAsync
void doEndRunAsync(WaitingTaskHolder iHolder, RunPrincipal const &principal, IOVSyncValue const &ts, std::vector< std::shared_ptr< const EventSetupImpl >> const *, bool cleaningUpAfterException)
Definition: SubProcess.cc:437
edm::beginGlobalTransitionAsync
void beginGlobalTransitionAsync(WaitingTaskHolder iWait, Schedule &iSchedule, P &iPrincipal, IOVSyncValue const &iTS, EventSetupImpl const &iES, std::vector< std::shared_ptr< const EventSetupImpl >> const *iEventSetupImpls, ServiceToken const &token, SC &iSubProcesses)
Definition: globalTransitionAsync.h:81
edm::SubProcess::doEndLuminosityBlockAsync
void doEndLuminosityBlockAsync(WaitingTaskHolder iHolder, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts, std::vector< std::shared_ptr< const EventSetupImpl >> const *, bool cleaningUpAfterException)
Definition: SubProcess.cc:522
edm::SubProcess::doBeginLuminosityBlockAsync
void doBeginLuminosityBlockAsync(WaitingTaskHolder iHolder, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts, std::vector< std::shared_ptr< const EventSetupImpl >> const *)
Definition: SubProcess.cc:493
edm::RunPrincipal
Definition: RunPrincipal.h:34
P
std::pair< OmniClusterRef, TrackingParticleRef > P
Definition: BDHadronTrackMonitoringAnalyzer.cc:202
IOVSyncValue.h
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316