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 EventSetup;
34  class LuminosityBlockPrincipal;
35  class RunPrincipal;
36 
37  //This is code in common between beginStreamRun and beginGlobalLuminosityBlock
39  iSubProcess.doBeginLuminosityBlockAsync(std::move(iHolder),iPrincipal, iTS);
40  }
41 
42  inline void subProcessDoGlobalBeginTransitionAsync(WaitingTaskHolder iHolder, SubProcess& iSubProcess, RunPrincipal& iPrincipal, IOVSyncValue const& iTS) {
43  iSubProcess.doBeginRunAsync(std::move(iHolder),iPrincipal, iTS);
44  }
45 
46  inline void subProcessDoGlobalEndTransitionAsync(WaitingTaskHolder iHolder, SubProcess& iSubProcess, LuminosityBlockPrincipal& iPrincipal, IOVSyncValue const& iTS, bool cleaningUpAfterException) {
47  iSubProcess.doEndLuminosityBlockAsync(std::move(iHolder),iPrincipal, iTS,cleaningUpAfterException);
48  }
49 
50  inline void subProcessDoGlobalEndTransitionAsync(WaitingTaskHolder iHolder, SubProcess& iSubProcess, RunPrincipal& iPrincipal, IOVSyncValue const& iTS, bool cleaningUpAfterException) {
51  iSubProcess.doEndRunAsync(std::move(iHolder), iPrincipal, iTS, cleaningUpAfterException);
52  }
53 
54  template<typename Traits, typename P, typename SC >
56  Schedule& iSchedule,
57  P& iPrincipal,
58  IOVSyncValue const & iTS,
59  EventSetup const& iES,
60  ServiceToken const& token,
61  SC& iSubProcesses) {
62 
63  //When we are done processing the global for this process,
64  // we need to run the global for all SubProcesses
65  auto subs = make_waiting_task(tbb::task::allocate_root(), [&iSubProcesses, iWait,&iPrincipal,iTS](std::exception_ptr const* iPtr) mutable {
66  if(iPtr) {
67  auto excpt = *iPtr;
68  auto delayError = make_waiting_task(tbb::task::allocate_root(), [iWait,excpt](std::exception_ptr const* ) mutable {
69  iWait.doneWaiting(excpt);
70  });
71  WaitingTaskHolder h(delayError);
72  for(auto& subProcess: iSubProcesses) {
73  subProcessDoGlobalBeginTransitionAsync(h,subProcess,iPrincipal, iTS);
74  }
75  } else {
76  for(auto& subProcess:iSubProcesses){
77  subProcessDoGlobalBeginTransitionAsync(iWait,subProcess,iPrincipal, iTS);
78  }
79  }
80  });
81 
82  WaitingTaskHolder h(subs);
83  iSchedule.processOneGlobalAsync<Traits>(std::move(h),iPrincipal, iES,token);
84  }
85 
86 
87  template<typename Traits, typename P, typename SC >
89  Schedule& iSchedule,
90  P& iPrincipal,
91  IOVSyncValue const & iTS,
92  EventSetup const& iES,
93  ServiceToken const& token,
94  SC& iSubProcesses,
95  bool cleaningUpAfterException)
96  {
97  //When we are done processing the global for this process,
98  // we need to run the global for all SubProcesses
99  auto subs = make_waiting_task(tbb::task::allocate_root(), [&iSubProcesses, iWait,&iPrincipal,iTS,cleaningUpAfterException](std::exception_ptr const* iPtr) mutable {
100  if(iPtr) {
101  auto excpt = *iPtr;
102  auto delayError = make_waiting_task(tbb::task::allocate_root(), [iWait,excpt](std::exception_ptr const* ) mutable {
103  iWait.doneWaiting(excpt);
104  });
105  WaitingTaskHolder h(delayError);
106  for(auto& subProcess: iSubProcesses){
107  subProcessDoGlobalEndTransitionAsync(h,subProcess,iPrincipal, iTS,cleaningUpAfterException);
108  }
109  } else {
110  for(auto& subProcess: iSubProcesses){
111  subProcessDoGlobalEndTransitionAsync(iWait,subProcess,iPrincipal, iTS,cleaningUpAfterException);
112  }
113  }
114  });
115 
116  WaitingTaskHolder h(subs);
117  iSchedule.processOneGlobalAsync<Traits>(std::move(h),iPrincipal, iES,token,cleaningUpAfterException);
118  }
119 
120 };
121 
122 #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:450
void doBeginLuminosityBlockAsync(WaitingTaskHolder iHolder, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:499
void doBeginRunAsync(WaitingTaskHolder iHolder, RunPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:420
void doEndLuminosityBlockAsync(WaitingTaskHolder iHolder, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:524
void subProcessDoGlobalBeginTransitionAsync(WaitingTaskHolder iHolder, SubProcess &iSubProcess, LuminosityBlockPrincipal &iPrincipal, IOVSyncValue const &iTS)
FunctorWaitingTask< F > * make_waiting_task(ALLOC &&iAlloc, F f)
Definition: WaitingTask.h:92
std::pair< OmniClusterRef, TrackingParticleRef > P
HLT enums.
void endGlobalTransitionAsync(WaitingTaskHolder iWait, Schedule &iSchedule, P &iPrincipal, IOVSyncValue const &iTS, EventSetup const &iES, ServiceToken const &token, SC &iSubProcesses, bool cleaningUpAfterException)
void beginGlobalTransitionAsync(WaitingTaskHolder iWait, Schedule &iSchedule, P &iPrincipal, IOVSyncValue const &iTS, EventSetup const &iES, ServiceToken const &token, SC &iSubProcesses)
void processOneGlobalAsync(WaitingTaskHolder iTask, typename T::MyPrincipal &principal, EventSetup const &eventSetup, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:325
def move(src, dest)
Definition: eostools.py:511