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  if(iPtr) {
67  iWait.doneWaiting(*iPtr);
68  return;
69  }
70  ServiceRegistry::Operate op(token);
71  for_all(iSubProcesses, [&iWait, &iPrincipal, iTS](auto& subProcess){ subProcessDoGlobalBeginTransitionAsync(iWait,subProcess,iPrincipal, iTS); });
72  });
73 
74  WaitingTaskHolder h(subs);
75  iSchedule.processOneGlobalAsync<Traits>(std::move(h),iPrincipal, iES);
76  }
77 
78 
79  template<typename Traits, typename P, typename SC >
81  Schedule& iSchedule,
82  P& iPrincipal,
83  IOVSyncValue const & iTS,
84  EventSetup const& iES,
85  SC& iSubProcesses,
86  bool cleaningUpAfterException)
87  {
89 
90  //When we are done processing the global for this process,
91  // we need to run the global for all SubProcesses
92  auto subs = make_waiting_task(tbb::task::allocate_root(), [&iSubProcesses, iWait,&iPrincipal,iTS,token,cleaningUpAfterException](std::exception_ptr const* iPtr) mutable {
93  if(iPtr) {
94  iWait.doneWaiting(*iPtr);
95  return;
96  }
97  ServiceRegistry::Operate op(token);
98  for_all(iSubProcesses, [&iWait, &iPrincipal, iTS,cleaningUpAfterException](auto& subProcess){
99  subProcessDoGlobalEndTransitionAsync(iWait,subProcess,iPrincipal, iTS,cleaningUpAfterException); });
100  });
101 
102  WaitingTaskHolder h(subs);
103  iSchedule.processOneGlobalAsync<Traits>(std::move(h),iPrincipal, iES,cleaningUpAfterException);
104 
105 
106  }
107 
108 };
109 
110 #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:90
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