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;
179 unsigned int iNumberOfChildren) = 0;
200 template <
typename T>
201 class ModuleSignalSentry {
204 typename T::Context
const* context,
206 a_(a), context_(context), moduleCallingContext_(moduleCallingContext) {
208 if(a_) T::preModuleSignal(a_, context, moduleCallingContext_);
211 ~ModuleSignalSentry() {
212 if(a_) T::postModuleSignal(a_, context_, moduleCallingContext_);
217 typename T::Context
const* context_;
221 template <
typename T>
222 void exceptionContext(
typename T::MyPrincipal
const&
principal,
224 ModuleCallingContext
const* mcc) {
226 ModuleCallingContext
const* imcc = mcc;
228 std::ostringstream iost;
229 iost <<
"Calling method for unscheduled module "
231 << imcc->moduleDescription()->moduleLabel() <<
"'";
233 imcc = imcc->moduleCallingContext();
236 std::ostringstream iost;
237 iost <<
"Calling method for unscheduled module "
238 << imcc->moduleDescription()->moduleName() <<
"/'"
239 << imcc->moduleDescription()->moduleLabel() <<
"' (probably inside some kind of mixing module)";
241 imcc = imcc->internalContext()->moduleCallingContext();
244 std::ostringstream iost;
245 iost <<
"Calling method for unscheduled module "
246 << imcc->moduleDescription()->moduleName() <<
"/'"
247 << imcc->moduleDescription()->moduleLabel() <<
"'";
249 imcc = imcc->moduleCallingContext();
251 std::ostringstream ost;
253 ost <<
"Calling event method";
260 ost <<
"Calling unknown function";
262 ost <<
" for module " << imcc->moduleDescription()->moduleName() <<
"/'" << imcc->moduleDescription()->moduleLabel() <<
"'";
267 ost <<
"Running path '";
268 ost << imcc->placeInPathContext()->pathContext()->pathName() <<
"'";
272 ost <<
"Processing ";
273 ost << principal.id();
278 namespace workerhelper {
289 return iWorker->
implDo(ep,es, mcc);
307 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
325 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
343 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
361 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
380 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
399 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
419 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
438 ModuleSignalSentry<Arg> cpp(actReg, context, mcc);
450 template <
typename T>
455 typename T::Context
const* context) {
464 case Pass:
return true;
465 case Fail:
return false;
488 for(
auto const& item : items) {
490 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 prePrefetchSelection(Worker *iWorker, StreamID id, typename Arg::MyPrincipal &ep, ModuleCallingContext const *mcc)
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
static bool prePrefetchSelection(Worker *iWorker, StreamID id, typename Arg::MyPrincipal &ep, ModuleCallingContext const *mcc)
std::string const & category() const
static bool prePrefetchSelection(Worker *iWorker, StreamID id, typename Arg::MyPrincipal &ep, ModuleCallingContext const *mcc)
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 implDoPrePrefetchSelection(StreamID id, EventPrincipal &ep, ModuleCallingContext const *mcc)=0
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
static bool prePrefetchSelection(Worker *iWorker, StreamID id, typename Arg::MyPrincipal &ep, ModuleCallingContext const *mcc)
static bool prePrefetchSelection(Worker *iWorker, StreamID id, typename Arg::MyPrincipal &ep, ModuleCallingContext const *mcc)
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
static bool prePrefetchSelection(Worker *iWorker, StreamID id, typename Arg::MyPrincipal &ep, ModuleCallingContext const *mcc)
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
static bool prePrefetchSelection(Worker *iWorker, StreamID id, typename Arg::MyPrincipal &ep, ModuleCallingContext const *mcc)
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
static bool prePrefetchSelection(Worker *iWorker, StreamID id, typename Arg::MyPrincipal &ep, ModuleCallingContext const *mcc)
OccurrenceTraits< LuminosityBlockPrincipal, BranchActionGlobalBegin > Arg
static bool prePrefetchSelection(Worker *iWorker, StreamID id, typename Arg::MyPrincipal &ep, ModuleCallingContext const *mcc)
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)