1 #ifndef FWCore_Framework_Worker_h
2 #define FWCore_Framework_Worker_h
44 #include "boost/shared_ptr.hpp"
56 class ProductHolderIndexHelper;
57 class ProductHolderIndexAndSkipBit;
61 namespace workerhelper {
81 typename T::Context
const* context);
174 unsigned int iNumberOfChildren) = 0;
195 template <
typename T>
196 class ModuleSignalSentry {
199 typename T::Context
const* context,
201 a_(a), context_(context), moduleCallingContext_(moduleCallingContext) {
203 if(a_) T::preModuleSignal(a_, context, moduleCallingContext_);
206 ~ModuleSignalSentry() {
207 if(a_) T::postModuleSignal(a_, context_, moduleCallingContext_);
212 typename T::Context
const* context_;
216 template <
typename T>
217 void exceptionContext(
typename T::MyPrincipal
const&
principal,
219 ModuleCallingContext
const* mcc) {
221 ModuleCallingContext
const* imcc = mcc;
223 std::ostringstream iost;
224 iost <<
"Calling method for unscheduled module "
226 << imcc->moduleDescription()->moduleLabel() <<
"'";
228 imcc = imcc->moduleCallingContext();
231 std::ostringstream iost;
232 iost <<
"Calling method for unscheduled module "
233 << imcc->moduleDescription()->moduleName() <<
"/'"
234 << imcc->moduleDescription()->moduleLabel() <<
"' (probably inside some kind of mixing module)";
236 imcc = imcc->internalContext()->moduleCallingContext();
239 std::ostringstream iost;
240 iost <<
"Calling method for unscheduled module "
241 << imcc->moduleDescription()->moduleName() <<
"/'"
242 << imcc->moduleDescription()->moduleLabel() <<
"'";
244 imcc = imcc->moduleCallingContext();
246 std::ostringstream ost;
248 ost <<
"Calling event method";
255 ost <<
"Calling unknown function";
257 ost <<
" for module " << imcc->moduleDescription()->moduleName() <<
"/'" << imcc->moduleDescription()->moduleLabel() <<
"'";
262 ost <<
"Running path '";
263 ost << imcc->placeInPathContext()->pathContext()->pathName() <<
"'";
267 ost <<
"Processing ";
268 ost << principal.id();
273 namespace workerhelper {
284 return iWorker->
implDo(ep,es, mcc);
297 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
310 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
323 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
336 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
350 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
363 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
377 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
390 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
396 template <
typename T>
402 typename T::Context
const* context) {
415 case Pass:
return true;
416 case Fail:
return false;
432 for(
auto const& item : items) {
434 bool skipCurrentProcess = item.skipCurrentProcess();
static bool call(Worker *iWorker, StreamID, LuminosityBlockPrincipal &ep, EventSetup const &es, ActivityRegistry *actReg, ModuleCallingContext const *mcc, Arg::Context const *context)
void pathFinished(EventPrincipal &)
void resetModuleDescription(ModuleDescription const *)
ModuleDescription const & description() const
void setState(State state)
void setEarlyDeleteHelper(EarlyDeleteHelper *iHelper)
ModuleCallingContext const * getTopModuleCallingContext() const
virtual void implPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)=0
OccurrenceTraits< LuminosityBlockPrincipal, BranchActionStreamBegin > Arg
boost::shared_ptr< ActivityRegistry > actReg_
static bool call(Worker *iWorker, StreamID id, LuminosityBlockPrincipal &ep, EventSetup const &es, ActivityRegistry *actReg, ModuleCallingContext const *mcc, Arg::Context const *context)
OccurrenceTraits< RunPrincipal, BranchActionGlobalEnd > Arg
void setActivityRegistry(boost::shared_ptr< ActivityRegistry > areg)
virtual void implRespondToCloseInputFile(FileBlock const &fb)=0
std::string const & moduleName() const
std::string const & category() const
bool doWork(typename T::MyPrincipal &, EventSetup const &c, CPUTimer *const timer, StreamID stream, ParentContext const &parentContext, typename T::Context const *context)
exception_actions::ActionCodes find(const std::string &category) const
unsigned int ProductHolderIndex
ActivityRegistry * activityRegistry()
void beginStream(StreamID id, StreamContext &streamContext)
virtual bool implDoStreamBegin(StreamID id, RunPrincipal &rp, EventSetup const &c, ModuleCallingContext const *mcc)=0
virtual void implPreForkReleaseResources()=0
virtual std::string workerType() const =0
virtual void itemsToGet(BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const =0
ExceptionToActionTable const * actions_
std::pair< double, double > timeCpuReal() const
EarlyDeleteHelper * earlyDeleteHelper_
ModuleCallingContext moduleCallingContext_
static bool call(Worker *iWorker, StreamID id, RunPrincipal &ep, EventSetup const &es, ActivityRegistry *actReg, ModuleCallingContext const *mcc, Arg::Context const *context)
virtual bool implDoBegin(RunPrincipal &rp, EventSetup const &c, ModuleCallingContext const *mcc)=0
virtual void updateLookup(BranchType iBranchType, ProductHolderIndexHelper const &)=0
Worker & operator=(Worker const &)=delete
boost::shared_ptr< CPUTimer > StopwatchPointer
virtual bool implDo(EventPrincipal &, EventSetup const &c, ModuleCallingContext const *mcc)=0
PathContext const * pathContext() const
OccurrenceTraits< RunPrincipal, BranchActionGlobalBegin > Arg
ModuleDescription const * descPtr() const
ModuleDescription const * moduleDescription() const
void printCmsExceptionWarning(char const *behavior, cms::Exception const &e, edm::JobReport *jobRep=0, int rc=-1)
OccurrenceTraits< LuminosityBlockPrincipal, BranchActionGlobalEnd > Arg
Worker(ModuleDescription const &iMD, ExceptionToActionTable const *iActions)
OccurrenceTraits< LuminosityBlockPrincipal, BranchActionStreamEnd > Arg
static bool call(Worker *iWorker, StreamID, LuminosityBlockPrincipal &ep, EventSetup const &es, ActivityRegistry *actReg, ModuleCallingContext const *mcc, Arg::Context const *context)
static bool call(Worker *iWorker, StreamID id, RunPrincipal &ep, EventSetup const &es, ActivityRegistry *actReg, ModuleCallingContext const *mcc, Arg::Context const *context)
virtual void implEndJob()=0
virtual std::vector< ProductHolderIndexAndSkipBit > const & itemsToGetFromEvent() const =0
virtual void modulesDependentUpon(std::vector< const char * > &oModuleLabels) const =0
void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)
virtual Types moduleType() const =0
OccurrenceTraits< EventPrincipal, BranchActionStreamBegin > Arg
void postDoEvent(EventPrincipal &)
boost::shared_ptr< cms::Exception > cached_exception_
OccurrenceTraits< RunPrincipal, BranchActionStreamBegin > Arg
virtual void implBeginJob()=0
void respondToOpenInputFile(FileBlock const &fb)
virtual void itemsMayGet(BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const =0
void addContext(std::string const &context)
virtual void implBeginStream(StreamID)=0
virtual void implEndStream(StreamID)=0
void respondToCloseInputFile(FileBlock const &fb)
void preForkReleaseResources()
void endStream(StreamID id, StreamContext &streamContext)
static bool call(Worker *iWorker, StreamID, EventPrincipal &ep, EventSetup const &es, ActivityRegistry *actReg, ModuleCallingContext const *mcc, Arg::Context const *context)
RunStopwatch::StopwatchPointer stopwatch_
auto wrap(F iFunc) -> decltype(iFunc())
virtual bool implDoEnd(RunPrincipal &rp, EventSetup const &c, ModuleCallingContext const *mcc)=0
OccurrenceTraits< LuminosityBlockPrincipal, BranchActionGlobalBegin > Arg
virtual void implRespondToOpenInputFile(FileBlock const &fb)=0
static bool call(Worker *iWorker, StreamID id, LuminosityBlockPrincipal &ep, EventSetup const &es, ActivityRegistry *actReg, ModuleCallingContext const *mcc, Arg::Context const *context)
PlaceInPathContext const * placeInPathContext() const
OccurrenceTraits< RunPrincipal, BranchActionStreamEnd > Arg
virtual bool implDoStreamEnd(StreamID id, RunPrincipal &rp, EventSetup const &c, ModuleCallingContext const *mcc)=0
static bool call(Worker *iWorker, StreamID, RunPrincipal &ep, EventSetup const &es, ActivityRegistry *actReg, ModuleCallingContext const *mcc, Arg::Context const *context)
static bool call(Worker *iWorker, StreamID, RunPrincipal &ep, EventSetup const &es, ActivityRegistry *actReg, ModuleCallingContext const *mcc, Arg::Context const *context)