CMS 3D CMS Logo

streamTransitionAsync.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_streamTransitionAsync_h
2 #define FWCore_Framework_streamTransitionAsync_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Framework
6 // Function: streamTransitionAsync
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 beginStreamLuminosityBlock
38  inline void subProcessDoStreamBeginTransitionAsync(WaitingTaskHolder iHolder,SubProcess& iSubProcess, unsigned int i, LuminosityBlockPrincipal& iPrincipal, IOVSyncValue const& iTS) {
39  iSubProcess.doStreamBeginLuminosityBlockAsync(std::move(iHolder),i,iPrincipal, iTS);
40  }
41 
42  inline void subProcessDoStreamBeginTransitionAsync(WaitingTaskHolder iHolder, SubProcess& iSubProcess, unsigned int i, RunPrincipal& iPrincipal, IOVSyncValue const& iTS) {
43  iSubProcess.doStreamBeginRunAsync(std::move(iHolder),i,iPrincipal, iTS);
44  }
45 
46  inline void subProcessDoStreamEndTransitionAsync(WaitingTaskHolder iHolder, SubProcess& iSubProcess, unsigned int i, LuminosityBlockPrincipal& iPrincipal, IOVSyncValue const& iTS, bool cleaningUpAfterException) {
47  iSubProcess.doStreamEndLuminosityBlockAsync(std::move(iHolder),i,iPrincipal, iTS,cleaningUpAfterException);
48  }
49 
50  inline void subProcessDoStreamEndTransitionAsync(WaitingTaskHolder iHolder, SubProcess& iSubProcess, unsigned int i, RunPrincipal& iPrincipal, IOVSyncValue const& iTS, bool cleaningUpAfterException) {
51  iSubProcess.doStreamEndRunAsync(std::move(iHolder), i ,iPrincipal, iTS, cleaningUpAfterException);
52  }
53 
54 
55  template<typename Traits, typename P, typename SC >
57  Schedule& iSchedule,
58  unsigned int iStreamIndex,
59  P& iPrincipal,
60  IOVSyncValue const & iTS,
61  EventSetup const& iES,
62  SC& iSubProcesses) {
64 
65  //When we are done processing the stream for this process,
66  // we need to run the stream for all SubProcesses
67  auto subs = make_waiting_task(tbb::task::allocate_root(), [&iSubProcesses, iWait,iStreamIndex,&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,iStreamIndex, &iPrincipal, iTS](auto& subProcess){ subProcessDoStreamBeginTransitionAsync(iWait,subProcess,iStreamIndex,iPrincipal, iTS); });
74  });
75 
76  WaitingTaskHolder h(subs);
77  iSchedule.processOneStreamAsync<Traits>(std::move(h), iStreamIndex,iPrincipal, iES);
78  }
79 
80 
81  template<typename Traits, typename P, typename SC >
83  Schedule& iSchedule,
84  unsigned int iNStreams,
85  P& iPrincipal,
86  IOVSyncValue const & iTS,
87  EventSetup const& iES,
88  SC& iSubProcesses)
89  {
90  WaitingTaskHolder holdUntilAllStreamsCalled(iWait);
91  for(unsigned int i=0; i<iNStreams;++i) {
92  beginStreamTransitionAsync<Traits>(WaitingTaskHolder(iWait), iSchedule,i,iPrincipal,iTS,iES,iSubProcesses);
93  }
94  }
95 
96  template<typename Traits, typename P, typename SC >
98  Schedule& iSchedule,
99  unsigned int iStreamIndex,
100  P& iPrincipal,
101  IOVSyncValue const & iTS,
102  EventSetup const& iES,
103  SC& iSubProcesses,
104  bool cleaningUpAfterException)
105  {
107 
108  //When we are done processing the stream for this process,
109  // we need to run the stream for all SubProcesses
110  auto subs = make_waiting_task(tbb::task::allocate_root(), [&iSubProcesses, iWait,iStreamIndex,&iPrincipal,iTS,token,cleaningUpAfterException](std::exception_ptr const* iPtr) mutable {
111  if(iPtr) {
112  iWait.doneWaiting(*iPtr);
113  return;
114  }
115  ServiceRegistry::Operate op(token);
116  for_all(iSubProcesses, [&iWait,iStreamIndex, &iPrincipal, iTS,cleaningUpAfterException](auto& subProcess){
117  subProcessDoStreamEndTransitionAsync(iWait,subProcess,iStreamIndex,iPrincipal, iTS,cleaningUpAfterException); });
118  });
119 
120  WaitingTaskHolder h(subs);
121  iSchedule.processOneStreamAsync<Traits>(std::move(h), iStreamIndex,iPrincipal, iES,cleaningUpAfterException);
122 
123 
124  }
125 
126  template<typename Traits, typename P, typename SC >
128  Schedule& iSchedule,
129  unsigned int iNStreams,
130  P& iPrincipal,
131  IOVSyncValue const & iTS,
132  EventSetup const& iES,
133  SC& iSubProcesses,
134  bool cleaningUpAfterException)
135  {
136  WaitingTaskHolder holdUntilAllStreamsCalled(iWait);
137  for(unsigned int i=0; i<iNStreams;++i) {
138  endStreamTransitionAsync<Traits>(WaitingTaskHolder(iWait),
139  iSchedule,i,
140  iPrincipal,iTS,iES,
141  iSubProcesses,cleaningUpAfterException);
142  }
143  }
144 };
145 
146 #endif
void doStreamBeginRunAsync(WaitingTaskHolder iHolder, unsigned int iID, RunPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:554
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
void doStreamEndRunAsync(WaitingTaskHolder iHolder, unsigned int iID, RunPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:585
void doStreamEndLuminosityBlockAsync(WaitingTaskHolder iHolder, unsigned int iID, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:643
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 subProcessDoStreamEndTransitionAsync(WaitingTaskHolder iHolder, SubProcess &iSubProcess, unsigned int i, LuminosityBlockPrincipal &iPrincipal, IOVSyncValue const &iTS, bool cleaningUpAfterException)
static ServiceRegistry & instance()
void subProcessDoStreamBeginTransitionAsync(WaitingTaskHolder iHolder, SubProcess &iSubProcess, unsigned int i, LuminosityBlockPrincipal &iPrincipal, IOVSyncValue const &iTS)
void doStreamBeginLuminosityBlockAsync(WaitingTaskHolder iHolder, unsigned int iID, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:612
FunctorWaitingTask< F > * make_waiting_task(ALLOC &&iAlloc, F f)
Definition: WaitingTask.h:90
std::pair< OmniClusterRef, TrackingParticleRef > P
HLT enums.
void beginStreamsTransitionAsync(WaitingTask *iWait, Schedule &iSchedule, unsigned int iNStreams, P &iPrincipal, IOVSyncValue const &iTS, EventSetup const &iES, SC &iSubProcesses)
void endStreamTransitionAsync(WaitingTaskHolder iWait, Schedule &iSchedule, unsigned int iStreamIndex, P &iPrincipal, IOVSyncValue const &iTS, EventSetup const &iES, SC &iSubProcesses, bool cleaningUpAfterException)
void beginStreamTransitionAsync(WaitingTaskHolder iWait, Schedule &iSchedule, unsigned int iStreamIndex, P &iPrincipal, IOVSyncValue const &iTS, EventSetup const &iES, SC &iSubProcesses)
void endStreamsTransitionAsync(WaitingTask *iWait, Schedule &iSchedule, unsigned int iNStreams, P &iPrincipal, IOVSyncValue const &iTS, EventSetup const &iES, SC &iSubProcesses, bool cleaningUpAfterException)
void processOneStreamAsync(WaitingTaskHolder iTask, unsigned int iStreamID, typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
Definition: Schedule.h:312
def move(src, dest)
Definition: eostools.py:510