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  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,token](std::exception_ptr const* iPtr) mutable {
66  ServiceRegistry::Operate op(token);
67  if(iPtr) {
68  auto excpt = *iPtr;
69  auto delayError = make_waiting_task(tbb::task::allocate_root(), [iWait,token,excpt](std::exception_ptr const* ) mutable {
70  ServiceRegistry::Operate op(token);
71  iWait.doneWaiting(excpt);
72  });
73  WaitingTaskHolder h(delayError);
74  for_all(iSubProcesses, [&h, &iPrincipal, iTS](auto& subProcess){ subProcessDoGlobalBeginTransitionAsync(h,subProcess,iPrincipal, iTS); });
75  } else {
76  for_all(iSubProcesses, [&iWait, &iPrincipal, iTS](auto& subProcess){ subProcessDoGlobalBeginTransitionAsync(iWait,subProcess,iPrincipal, iTS); });
77  }
78  });
79 
80  WaitingTaskHolder h(subs);
81  iSchedule.processOneGlobalAsync<Traits>(std::move(h),iPrincipal, iES);
82  }
83 
84 
85  template<typename Traits, typename P, typename SC >
87  Schedule& iSchedule,
88  P& iPrincipal,
89  IOVSyncValue const & iTS,
90  EventSetup const& iES,
91  SC& iSubProcesses,
92  bool cleaningUpAfterException)
93  {
95 
96  //When we are done processing the global for this process,
97  // we need to run the global for all SubProcesses
98  auto subs = make_waiting_task(tbb::task::allocate_root(), [&iSubProcesses, iWait,&iPrincipal,iTS,token,cleaningUpAfterException](std::exception_ptr const* iPtr) mutable {
99  ServiceRegistry::Operate op(token);
100  if(iPtr) {
101  auto excpt = *iPtr;
102  auto delayError = make_waiting_task(tbb::task::allocate_root(), [iWait,token,excpt](std::exception_ptr const* ) mutable {
103  ServiceRegistry::Operate op(token);
104  iWait.doneWaiting(excpt);
105  });
106  WaitingTaskHolder h(delayError);
107  for_all(iSubProcesses, [&h, &iPrincipal, iTS,cleaningUpAfterException](auto& subProcess){
108  subProcessDoGlobalEndTransitionAsync(h,subProcess,iPrincipal, iTS,cleaningUpAfterException); });
109  } else {
110  for_all(iSubProcesses, [&iWait, &iPrincipal, iTS,cleaningUpAfterException](auto& subProcess){
111  subProcessDoGlobalEndTransitionAsync(iWait,subProcess,iPrincipal, iTS,cleaningUpAfterException); });
112  }
113  });
114 
115  WaitingTaskHolder h(subs);
116  iSchedule.processOneGlobalAsync<Traits>(std::move(h),iPrincipal, iES,cleaningUpAfterException);
117 
118 
119  }
120 
121 };
122 
123 #endif
void processOneGlobalAsync(WaitingTaskHolder iTask, typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
Definition: Schedule.h:313
void beginGlobalTransitionAsync(WaitingTaskHolder iWait, Schedule &iSchedule, P &iPrincipal, IOVSyncValue const &iTS, EventSetup const &iES, SC &iSubProcesses)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
ServiceToken presentToken() const
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
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:440
void doBeginLuminosityBlockAsync(WaitingTaskHolder iHolder, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:478
void doBeginRunAsync(WaitingTaskHolder iHolder, RunPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:411
static ServiceRegistry & instance()
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)
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, SC &iSubProcesses, bool cleaningUpAfterException)
def move(src, dest)
Definition: eostools.py:510