1 #ifndef FWCore_Framework_Worker_h
2 #define FWCore_Framework_Worker_h
57 class ProductHolderIndexHelper;
58 class ProductHolderIndexAndSkipBit;
61 class ProductRegistry;
62 class ThinnedAssociationsHelper;
64 namespace workerhelper {
83 typename T::Context
const* context);
112 virtual void modulesDependentUpon(std::vector<const char*>& oModuleLabels,
bool iPrint)
const = 0;
116 std::map<std::string, ModuleDescription const*>
const& labelsToDesc)
const = 0;
118 virtual std::vector<ConsumesInfo>
consumesInfo()
const = 0;
180 unsigned int iNumberOfChildren) = 0;
201 template <
typename T>
202 class ModuleSignalSentry {
205 typename T::Context
const* context,
207 a_(a), context_(context), moduleCallingContext_(moduleCallingContext) {
209 if(a_) T::preModuleSignal(a_, context, moduleCallingContext_);
212 ~ModuleSignalSentry() {
213 if(a_) T::postModuleSignal(a_, context_, moduleCallingContext_);
218 typename T::Context
const* context_;
222 template <
typename T>
223 void exceptionContext(
typename T::MyPrincipal
const&
principal,
225 ModuleCallingContext
const* mcc) {
227 ModuleCallingContext
const* imcc = mcc;
229 std::ostringstream iost;
230 iost <<
"Calling method for unscheduled module "
232 << imcc->moduleDescription()->moduleLabel() <<
"'";
234 imcc = imcc->moduleCallingContext();
237 std::ostringstream iost;
238 iost <<
"Calling method for unscheduled module "
239 << imcc->moduleDescription()->moduleName() <<
"/'"
240 << imcc->moduleDescription()->moduleLabel() <<
"' (probably inside some kind of mixing module)";
242 imcc = imcc->internalContext()->moduleCallingContext();
245 std::ostringstream iost;
246 iost <<
"Calling method for unscheduled module "
247 << imcc->moduleDescription()->moduleName() <<
"/'"
248 << imcc->moduleDescription()->moduleLabel() <<
"'";
250 imcc = imcc->moduleCallingContext();
252 std::ostringstream ost;
254 ost <<
"Calling event method";
261 ost <<
"Calling unknown function";
263 ost <<
" for module " << imcc->moduleDescription()->moduleName() <<
"/'" << imcc->moduleDescription()->moduleLabel() <<
"'";
268 ost <<
"Running path '";
269 ost << imcc->placeInPathContext()->pathContext()->pathName() <<
"'";
273 ost <<
"Processing ";
274 ost << principal.id();
279 namespace workerhelper {
290 return iWorker->
implDo(ep,es, mcc);
308 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
326 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
344 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
362 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
381 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
400 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
420 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
439 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
451 template <
typename T>
456 typename T::Context
const* context) {
465 case Pass:
return true;
466 case Fail:
return false;
489 for(
auto const& item : items) {
491 bool skipCurrentProcess = item.skipCurrentProcess();
static bool call(Worker *iWorker, StreamID, LuminosityBlockPrincipal const &ep, EventSetup const &es, ActivityRegistry *actReg, ModuleCallingContext const *mcc, Arg::Context const *context)
void resetModuleDescription(ModuleDescription const *)
ModuleDescription const & description() const
virtual bool implDoStreamBegin(StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc)=0
void setState(State state)
void setEarlyDeleteHelper(EarlyDeleteHelper *iHelper)
virtual void modulesWhoseProductsAreConsumed(std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc) const =0
static bool prePrefetchSelection(Worker *iWorker, StreamID id, typename Arg::MyPrincipal const &ep, ModuleCallingContext const *mcc)
ModuleCallingContext const * getTopModuleCallingContext() const
virtual void implPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)=0
static bool call(Worker *iWorker, StreamID id, RunPrincipal const &ep, EventSetup const &es, ActivityRegistry *actReg, ModuleCallingContext const *mcc, Arg::Context const *context)
OccurrenceTraits< LuminosityBlockPrincipal, BranchActionStreamBegin > Arg
OccurrenceTraits< RunPrincipal, BranchActionGlobalEnd > Arg
virtual void implRespondToCloseInputFile(FileBlock const &fb)=0
std::shared_ptr< ActivityRegistry > actReg_
bool doWork(typename T::MyPrincipal const &, EventSetup const &c, StreamID stream, ParentContext const &parentContext, typename T::Context const *context)
static bool call(Worker *iWorker, StreamID, LuminosityBlockPrincipal const &ep, EventSetup const &es, ActivityRegistry *actReg, ModuleCallingContext const *mcc, Arg::Context const *context)
std::string const & moduleName() const
std::string const & category() const
static bool call(Worker *iWorker, StreamID, RunPrincipal const &ep, EventSetup const &es, ActivityRegistry *actReg, ModuleCallingContext const *mcc, Arg::Context const *context)
exception_actions::ActionCodes find(const std::string &category) const
static bool call(Worker *iWorker, StreamID, EventPrincipal const &ep, EventSetup const &es, ActivityRegistry *, ModuleCallingContext const *mcc, Arg::Context const *)
static bool prePrefetchSelection(Worker *iWorker, StreamID id, typename Arg::MyPrincipal const &ep, ModuleCallingContext const *mcc)
static bool prePrefetchSelection(Worker *iWorker, StreamID id, typename Arg::MyPrincipal const &ep, ModuleCallingContext const *mcc)
unsigned int ProductHolderIndex
ActivityRegistry * activityRegistry()
static bool call(Worker *iWorker, StreamID id, LuminosityBlockPrincipal const &ep, EventSetup const &es, ActivityRegistry *actReg, ModuleCallingContext const *mcc, Arg::Context const *context)
void beginStream(StreamID id, StreamContext &streamContext)
virtual void implPreForkReleaseResources()=0
static bool prePrefetchSelection(Worker *iWorker, StreamID id, typename Arg::MyPrincipal const &ep, ModuleCallingContext const *mcc)
virtual std::string workerType() const =0
virtual void itemsToGet(BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const =0
ExceptionToActionTable const * actions_
void setActivityRegistry(std::shared_ptr< ActivityRegistry > areg)
ModuleCallingContext moduleCallingContext_
virtual void updateLookup(BranchType iBranchType, ProductHolderIndexHelper const &)=0
Worker & operator=(Worker const &)=delete
virtual bool implDoEnd(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc)=0
virtual void implRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &)=0
PathContext const * pathContext() const
OccurrenceTraits< RunPrincipal, BranchActionGlobalBegin > Arg
ModuleDescription const * descPtr() const
virtual bool implDoBegin(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc)=0
ModuleDescription const * moduleDescription() const
static bool prePrefetchSelection(Worker *iWorker, StreamID id, typename Arg::MyPrincipal const &ep, ModuleCallingContext const *mcc)
virtual std::vector< ConsumesInfo > consumesInfo() const =0
void registerThinnedAssociations(ProductRegistry const ®istry, ThinnedAssociationsHelper &helper)
OccurrenceTraits< LuminosityBlockPrincipal, BranchActionGlobalEnd > Arg
Worker(ModuleDescription const &iMD, ExceptionToActionTable const *iActions)
static bool call(Worker *iWorker, StreamID id, RunPrincipal const &ep, EventSetup const &es, ActivityRegistry *actReg, ModuleCallingContext const *mcc, Arg::Context const *context)
static bool call(Worker *iWorker, StreamID, RunPrincipal const &ep, EventSetup const &es, ActivityRegistry *actReg, ModuleCallingContext const *mcc, Arg::Context const *context)
edm::propagate_const< std::shared_ptr< cms::Exception > > cached_exception_
OccurrenceTraits< LuminosityBlockPrincipal, BranchActionStreamEnd > Arg
virtual void implEndJob()=0
virtual std::vector< ProductHolderIndexAndSkipBit > const & itemsToGetFromEvent() const =0
void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)
virtual Types moduleType() const =0
OccurrenceTraits< EventPrincipal, BranchActionStreamBegin > Arg
virtual bool implDoPrePrefetchSelection(StreamID id, EventPrincipal const &ep, ModuleCallingContext const *mcc)=0
OccurrenceTraits< RunPrincipal, BranchActionStreamBegin > Arg
virtual void implBeginJob()=0
void respondToOpenInputFile(FileBlock const &fb)
virtual void itemsMayGet(BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const =0
void pathFinished(EventPrincipal const &)
void addContext(std::string const &context)
virtual void implBeginStream(StreamID)=0
virtual void modulesDependentUpon(std::vector< const char * > &oModuleLabels, bool iPrint) const =0
static bool call(Worker *iWorker, StreamID id, LuminosityBlockPrincipal const &ep, EventSetup const &es, ActivityRegistry *actReg, ModuleCallingContext const *mcc, Arg::Context const *context)
virtual void implEndStream(StreamID)=0
void respondToCloseInputFile(FileBlock const &fb)
void preForkReleaseResources()
static bool prePrefetchSelection(Worker *iWorker, StreamID id, typename Arg::MyPrincipal const &ep, ModuleCallingContext const *mcc)
virtual bool implDo(EventPrincipal const &, EventSetup const &c, ModuleCallingContext const *mcc)=0
void endStream(StreamID id, StreamContext &streamContext)
void postDoEvent(EventPrincipal const &)
virtual bool implDoStreamEnd(StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc)=0
auto wrap(F iFunc) -> decltype(iFunc())
edm::propagate_const< EarlyDeleteHelper * > earlyDeleteHelper_
static bool prePrefetchSelection(Worker *iWorker, StreamID id, typename Arg::MyPrincipal const &ep, ModuleCallingContext const *mcc)
OccurrenceTraits< LuminosityBlockPrincipal, BranchActionGlobalBegin > Arg
static bool prePrefetchSelection(Worker *iWorker, StreamID id, typename Arg::MyPrincipal const &ep, ModuleCallingContext const *mcc)
virtual void implRespondToOpenInputFile(FileBlock const &fb)=0
PlaceInPathContext const * placeInPathContext() const
OccurrenceTraits< RunPrincipal, BranchActionStreamEnd > Arg
static bool prePrefetchSelection(Worker *iWorker, StreamID id, typename Arg::MyPrincipal const &ep, ModuleCallingContext const *mcc)
void printCmsExceptionWarning(char const *behavior, cms::Exception const &e)