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
26 
27 // user include files
28 
29 // forward declarations
30 
31 namespace edm {
32  class IOVSyncValue;
33  class EventSetupImpl;
34  class LuminosityBlockPrincipal;
35  class RunPrincipal;
36 
37  //This is code in common between beginStreamRun and beginGlobalLuminosityBlock
39  SubProcess& iSubProcess,
40  LuminosityBlockPrincipal& iPrincipal,
41  IOVSyncValue const& iTS) {
42  iSubProcess.doBeginLuminosityBlockAsync(std::move(iHolder), iPrincipal, iTS);
43  }
44 
46  SubProcess& iSubProcess,
47  RunPrincipal& iPrincipal,
48  IOVSyncValue const& iTS) {
49  iSubProcess.doBeginRunAsync(std::move(iHolder), iPrincipal, iTS);
50  }
51 
53  SubProcess& iSubProcess,
54  LuminosityBlockPrincipal& iPrincipal,
55  IOVSyncValue const& iTS,
56  bool cleaningUpAfterException) {
57  iSubProcess.doEndLuminosityBlockAsync(std::move(iHolder), iPrincipal, iTS, cleaningUpAfterException);
58  }
59 
61  SubProcess& iSubProcess,
62  RunPrincipal& iPrincipal,
63  IOVSyncValue const& iTS,
64  bool cleaningUpAfterException) {
65  iSubProcess.doEndRunAsync(std::move(iHolder), iPrincipal, iTS, cleaningUpAfterException);
66  }
67 
68  template <typename Traits, typename P, typename SC>
70  Schedule& iSchedule,
71  P& iPrincipal,
72  IOVSyncValue const& iTS,
73  EventSetupImpl const& iES,
74  ServiceToken const& token,
75  SC& iSubProcesses) {
76  //When we are done processing the global for this process,
77  // we need to run the global for all SubProcesses
78  auto subs = make_waiting_task(
79  tbb::task::allocate_root(), [&iSubProcesses, iWait, &iPrincipal, iTS](std::exception_ptr const* iPtr) mutable {
80  if (iPtr) {
81  auto excpt = *iPtr;
82  auto delayError =
83  make_waiting_task(tbb::task::allocate_root(),
84  [iWait, excpt](std::exception_ptr const*) mutable { iWait.doneWaiting(excpt); });
85  WaitingTaskHolder h(delayError);
86  for (auto& subProcess : iSubProcesses) {
87  subProcessDoGlobalBeginTransitionAsync(h, subProcess, iPrincipal, iTS);
88  }
89  } else {
90  for (auto& subProcess : iSubProcesses) {
91  subProcessDoGlobalBeginTransitionAsync(iWait, subProcess, iPrincipal, iTS);
92  }
93  }
94  });
95 
96  WaitingTaskHolder h(subs);
97  iSchedule.processOneGlobalAsync<Traits>(std::move(h), iPrincipal, iES, token);
98  }
99 
100  template <typename Traits, typename P, typename SC>
102  Schedule& iSchedule,
103  P& iPrincipal,
104  IOVSyncValue const& iTS,
105  EventSetupImpl const& iES,
106  ServiceToken const& token,
107  SC& iSubProcesses,
108  bool cleaningUpAfterException) {
109  //When we are done processing the global for this process,
110  // we need to run the global for all SubProcesses
111  auto subs = make_waiting_task(
112  tbb::task::allocate_root(),
113  [&iSubProcesses, iWait, &iPrincipal, iTS, cleaningUpAfterException](std::exception_ptr const* iPtr) mutable {
114  if (iPtr) {
115  auto excpt = *iPtr;
116  auto delayError =
117  make_waiting_task(tbb::task::allocate_root(),
118  [iWait, excpt](std::exception_ptr const*) mutable { iWait.doneWaiting(excpt); });
119  WaitingTaskHolder h(delayError);
120  for (auto& subProcess : iSubProcesses) {
121  subProcessDoGlobalEndTransitionAsync(h, subProcess, iPrincipal, iTS, cleaningUpAfterException);
122  }
123  } else {
124  for (auto& subProcess : iSubProcesses) {
125  subProcessDoGlobalEndTransitionAsync(iWait, subProcess, iPrincipal, iTS, cleaningUpAfterException);
126  }
127  }
128  });
129 
130  WaitingTaskHolder h(subs);
131  iSchedule.processOneGlobalAsync<Traits>(std::move(h), iPrincipal, iES, token, cleaningUpAfterException);
132  }
133 
134 }; // namespace edm
135 
136 #endif
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
void subProcessDoGlobalEndTransitionAsync(WaitingTaskHolder iHolder, SubProcess &iSubProcess, LuminosityBlockPrincipal &iPrincipal, IOVSyncValue const &iTS, bool cleaningUpAfterException)
void doneWaiting(std::exception_ptr iExcept)
void doEndRunAsync(WaitingTaskHolder iHolder, RunPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:426
void doBeginLuminosityBlockAsync(WaitingTaskHolder iHolder, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:480
void doBeginRunAsync(WaitingTaskHolder iHolder, RunPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:398
void doEndLuminosityBlockAsync(WaitingTaskHolder iHolder, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:501
void subProcessDoGlobalBeginTransitionAsync(WaitingTaskHolder iHolder, SubProcess &iSubProcess, LuminosityBlockPrincipal &iPrincipal, IOVSyncValue const &iTS)
void endGlobalTransitionAsync(WaitingTaskHolder iWait, Schedule &iSchedule, P &iPrincipal, IOVSyncValue const &iTS, EventSetupImpl const &iES, ServiceToken const &token, SC &iSubProcesses, bool cleaningUpAfterException)
FunctorWaitingTask< F > * make_waiting_task(ALLOC &&iAlloc, F f)
Definition: WaitingTask.h:87
std::pair< OmniClusterRef, TrackingParticleRef > P
HLT enums.
def move(src, dest)
Definition: eostools.py:511
void beginGlobalTransitionAsync(WaitingTaskHolder iWait, Schedule &iSchedule, P &iPrincipal, IOVSyncValue const &iTS, EventSetupImpl const &iES, ServiceToken const &token, SC &iSubProcesses)
void processOneGlobalAsync(WaitingTaskHolder iTask, typename T::MyPrincipal &principal, EventSetupImpl const &eventSetup, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:330