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  /*Not implemented yet
47  inline void subProcessDoGlobalEndTransitionAsync(WaitingTaskHolder iHolder, SubProcess& iSubProcess, LuminosityBlockPrincipal& iPrincipal, IOVSyncValue const& iTS, bool cleaningUpAfterException) {
48  iSubProcess.doEndLuminosityBlockAsync(std::move(iHolder),iPrincipal, iTS,cleaningUpAfterException);
49  }
50 
51  inline void subProcessDoGlobalEndTransitionAsync(WaitingTaskHolder iHolder, SubProcess& iSubProcess, RunPrincipal& iPrincipal, IOVSyncValue const& iTS, bool cleaningUpAfterException) {
52  iSubProcess.doEndRunAsync(std::move(iHolder), iPrincipal, iTS, cleaningUpAfterException);
53  }
54  */
55 
56  template<typename Traits, typename P, typename SC >
58  Schedule& iSchedule,
59  P& iPrincipal,
60  IOVSyncValue const & iTS,
61  EventSetup const& iES,
62  SC& iSubProcesses) {
64 
65  //When we are done processing the global for this process,
66  // we need to run the global for all SubProcesses
67  auto subs = make_waiting_task(tbb::task::allocate_root(), [&iSubProcesses, iWait,&iPrincipal,iTS,token](std::exception_ptr const* iPtr) mutable {
68  if(iPtr) {
69  iWait.doneWaiting(*iPtr);
70  return;
71  }
72  ServiceRegistry::Operate op(token);
73  for_all(iSubProcesses, [&iWait, &iPrincipal, iTS](auto& subProcess){ subProcessDoGlobalBeginTransitionAsync(iWait,subProcess,iPrincipal, iTS); });
74  });
75 
76  WaitingTaskHolder h(subs);
77  iSchedule.processOneGlobalAsync<Traits>(std::move(h),iPrincipal, iES);
78  }
79 
80 
81  template<typename Traits, typename P, typename SC >
83  Schedule& iSchedule,
84  P& iPrincipal,
85  IOVSyncValue const & iTS,
86  EventSetup const& iES,
87  SC& iSubProcesses,
88  bool cleaningUpAfterException)
89  {
91 
92  //When we are done processing the global for this process,
93  // we need to run the global for all SubProcesses
94  auto subs = make_waiting_task(tbb::task::allocate_root(), [&iSubProcesses, iWait,&iPrincipal,iTS,token,cleaningUpAfterException](std::exception_ptr const* iPtr) mutable {
95  if(iPtr) {
96  iWait.doneWaiting(*iPtr);
97  return;
98  }
99  ServiceRegistry::Operate op(token);
100  for_all(iSubProcesses, [&iWait, &iPrincipal, iTS,cleaningUpAfterException](auto& subProcess){
101  subProcessDoGlobalEndTransitionAsync(iWait,subProcess,iPrincipal, iTS,cleaningUpAfterException); });
102  });
103 
104  WaitingTaskHolder h(subs);
105  iSchedule.processOneGlobalAsync<Traits>(std::move(h),iPrincipal, iES,cleaningUpAfterException);
106 
107 
108  }
109 
110 };
111 
112 #endif
void processOneGlobalAsync(WaitingTaskHolder iTask, typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
Definition: Schedule.h:340
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 doneWaiting(std::exception_ptr iExcept)
void doBeginLuminosityBlockAsync(WaitingTaskHolder iHolder, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:527
void doBeginRunAsync(WaitingTaskHolder iHolder, RunPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:439
static ServiceRegistry & instance()
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