1 #ifndef FWCore_Framework_GlobalSchedule_h 2 #define FWCore_Framework_GlobalSchedule_h 31 #include "boost/range/adaptor/reversed.hpp" 38 class GlobalScheduleSignalSentry {
40 GlobalScheduleSignalSentry(
ActivityRegistry*
a,
typename T::Context
const* context) :
41 a_(a), context_(context),
43 if (a_) T::preScheduleSignal(a_, context_);
47 if (a_) T::postScheduleSignal(a_, context_);
49 if(allowThrow_) {
throw;}
60 typename T::Context
const* context_;
67 class ExceptionCollector;
69 class PreallocationConfiguration;
71 class TriggerResultInserter;
72 class PathStatusInserter;
73 class EndPathStatusInserter;
84 std::vector<
edm::propagate_const<std::shared_ptr<EndPathStatusInserter>>>& endPathStatusInserters,
85 std::shared_ptr<ModuleRegistry> modReg,
86 std::vector<std::string>
const& modulesToUse,
91 std::shared_ptr<ActivityRegistry> areg,
92 std::shared_ptr<ProcessConfiguration> processConfiguration,
97 void processOneGlobal(
typename T::MyPrincipal&
principal,
99 bool cleaningUpAfterException =
false);
101 template <
typename T>
105 bool cleaningUpAfterException =
false);
116 std::vector<ModuleDescription const*> getAllModuleDescriptions()
const;
123 bool terminate()
const;
130 return workerManager_.allWorkers();
158 void runNow(
typename T::MyPrincipal
const&
p,
EventSetup const& es,
163 return workerManager_.actionTable();
166 void addToAllWorkers(
Worker*
w);
178 template <
typename T>
182 bool cleaningUpAfterException) {
183 GlobalContext globalContext = T::makeGlobalContext(ep, processContext_);
185 GlobalScheduleSignalSentry<T> sentry(actReg_.get(), &globalContext);
192 ep.resetFailedFromThisProcess();
195 workerManager_.processOneOccurrence<
T>(ep, es,
StreamID::invalidStreamID(), &globalContext, &globalContext, cleaningUpAfterException);
199 runNow<T>(ep,es,&globalContext);
210 terminationSentry.completedSuccessfully();
216 template <
typename T>
219 typename T::MyPrincipal& ep,
221 bool cleaningUpAfterException) {
225 auto globalContext = std::make_shared<GlobalContext>(T::makeGlobalContext(ep, processContext_));
228 T::preScheduleSignal(actReg_.get(), globalContext.get());
235 ep.resetFailedFromThisProcess();
239 [
this,iHolder, cleaningUpAfterException, globalContext, token](std::exception_ptr
const* iPtr)
mutable 242 std::exception_ptr excpt;
248 std::rethrow_exception(excpt);
252 std::ostringstream ost;
254 ost<<
"Processing "<<T::transitionName()<<
" ";
257 excpt = std::current_exception();
265 T::postScheduleSignal(actReg_.get(), globalContext.get());
268 excpt = std::current_exception();
275 workerManager_.resetAll();
280 workerManager_.setupOnDemandSystem(ep,es);
290 template <
typename T>
295 for(
auto & worker: allWorkers()) {
302 std::ostringstream ost;
303 ost <<
"Processing " <<T::transitionName()<<
" "<< p.id();
void processOneGlobal(typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
std::vector< std::string > vstring
edm::propagate_const< WorkerPtr > results_inserter_
std::vector< edm::propagate_const< WorkerPtr > > endPathStatusInserterWorkers_
roAction_t actions[nactions]
std::vector< Worker * > AllWorkers
void addContextAndPrintException(char const *context, cms::Exception &ex, bool disablePrint)
void runNow(typename T::MyPrincipal const &p, EventSetup const &es, GlobalContext const *context)
edm::ActivityRegistry * reg_
static StreamID invalidStreamID()
ServiceToken presentToken() const
void processOneGlobalAsync(WaitingTaskHolder holder, typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
void doneWaiting(std::exception_ptr iExcept)
std::vector< Worker * > Workers
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
std::list< std::string > const & context() const
static ServiceRegistry & instance()
std::shared_ptr< Worker > WorkerPtr
std::shared_ptr< ActivityRegistry > actReg_
~SendTerminationSignalIfException()
FunctorWaitingTask< F > * make_waiting_task(ALLOC &&iAlloc, F f)
void addContext(std::string const &context)
SendTerminationSignalIfException(edm::ActivityRegistry *iReg, edm::GlobalContext const *iContext)
ExceptionToActionTable const & actionTable() const
returns the action table
GlobalContext const * context_
std::vector< edm::propagate_const< WorkerPtr > > pathStatusInserterWorkers_
auto wrap(F iFunc) -> decltype(iFunc())
ProcessContext const * processContext_
WorkerManager workerManager_
void completedSuccessfully()