1 #ifndef FWCore_Framework_Worker_h
2 #define FWCore_Framework_Worker_h
56 class ProductHolderIndexHelper;
57 class ProductHolderIndexAndSkipBit;
60 class ProductRegistry;
61 class ThinnedAssociationsHelper;
63 namespace workerhelper {
82 typename T::Context
const* context);
115 std::map<std::string, ModuleDescription const*>
const& labelsToDesc)
const = 0;
117 virtual std::vector<ConsumesInfo>
consumesInfo()
const = 0;
176 unsigned int iNumberOfChildren) = 0;
197 template <
typename T>
198 class ModuleSignalSentry {
201 typename T::Context
const* context,
203 a_(a), context_(context), moduleCallingContext_(moduleCallingContext) {
205 if(a_) T::preModuleSignal(a_, context, moduleCallingContext_);
208 ~ModuleSignalSentry() {
209 if(a_) T::postModuleSignal(a_, context_, moduleCallingContext_);
214 typename T::Context
const* context_;
218 template <
typename T>
219 void exceptionContext(
typename T::MyPrincipal
const&
principal,
221 ModuleCallingContext
const* mcc) {
223 ModuleCallingContext
const* imcc = mcc;
225 std::ostringstream iost;
226 iost <<
"Calling method for unscheduled module "
228 << imcc->moduleDescription()->moduleLabel() <<
"'";
230 imcc = imcc->moduleCallingContext();
233 std::ostringstream iost;
234 iost <<
"Calling method for unscheduled module "
235 << imcc->moduleDescription()->moduleName() <<
"/'"
236 << imcc->moduleDescription()->moduleLabel() <<
"' (probably inside some kind of mixing module)";
238 imcc = imcc->internalContext()->moduleCallingContext();
241 std::ostringstream iost;
242 iost <<
"Calling method for unscheduled module "
243 << imcc->moduleDescription()->moduleName() <<
"/'"
244 << imcc->moduleDescription()->moduleLabel() <<
"'";
246 imcc = imcc->moduleCallingContext();
248 std::ostringstream ost;
250 ost <<
"Calling event method";
257 ost <<
"Calling unknown function";
259 ost <<
" for module " << imcc->moduleDescription()->moduleName() <<
"/'" << imcc->moduleDescription()->moduleLabel() <<
"'";
264 ost <<
"Running path '";
265 ost << imcc->placeInPathContext()->pathContext()->pathName() <<
"'";
269 ost <<
"Processing ";
270 ost << principal.id();
275 namespace workerhelper {
286 return iWorker->
implDo(ep,es, mcc);
299 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
312 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
325 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
338 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
352 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
365 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
379 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
392 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
398 template <
typename T>
403 typename T::Context
const* context) {
412 case Pass:
return true;
413 case Fail:
return false;
429 for(
auto const& item : items) {
431 bool skipCurrentProcess = item.skipCurrentProcess();
static bool call(Worker *iWorker, StreamID, LuminosityBlockPrincipal &ep, EventSetup const &es, ActivityRegistry *actReg, ModuleCallingContext const *mcc, Arg::Context const *context)
bool doWork(typename T::MyPrincipal &, EventSetup const &c, StreamID stream, ParentContext const &parentContext, typename T::Context const *context)
void pathFinished(EventPrincipal &)
void resetModuleDescription(ModuleDescription const *)
ModuleDescription const & description() const
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
ModuleCallingContext const * getTopModuleCallingContext() const
virtual void implPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)=0
OccurrenceTraits< LuminosityBlockPrincipal, BranchActionStreamBegin > Arg
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
virtual void implRespondToCloseInputFile(FileBlock const &fb)=0
std::shared_ptr< ActivityRegistry > actReg_
std::string const & moduleName() const
std::string const & category() const
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_
void setActivityRegistry(std::shared_ptr< ActivityRegistry > areg)
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
virtual void implRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &)=0
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
virtual std::vector< ConsumesInfo > consumesInfo() const =0
void registerThinnedAssociations(ProductRegistry const ®istry, ThinnedAssociationsHelper &helper)
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 &)
OccurrenceTraits< RunPrincipal, BranchActionStreamBegin > Arg
virtual void implBeginJob()=0
void respondToOpenInputFile(FileBlock const &fb)
virtual void itemsMayGet(BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const =0
static bool call(Worker *iWorker, StreamID, EventPrincipal &ep, EventSetup const &es, ActivityRegistry *, ModuleCallingContext const *mcc, Arg::Context const *)
void addContext(std::string const &context)
virtual void implBeginStream(StreamID)=0
virtual void implEndStream(StreamID)=0
void respondToCloseInputFile(FileBlock const &fb)
void preForkReleaseResources()
std::shared_ptr< cms::Exception > cached_exception_
void endStream(StreamID id, StreamContext &streamContext)
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)