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);
171 unsigned int iNumberOfChildren) = 0;
192 template <
typename T>
193 class ModuleSignalSentry {
197 typename T::Context
const* context,
199 a_(a), md_(&md), context_(context), moduleCallingContext_(moduleCallingContext) {
201 if(a_) T::preModuleSignal(a_, md_, context, moduleCallingContext_);
204 ~ModuleSignalSentry() {
205 if(a_) T::postModuleSignal(a_, md_, context_, moduleCallingContext_);
211 typename T::Context
const* context_;
215 template <
typename T>
216 void exceptionContext(
typename T::MyPrincipal
const&
principal,
218 ModuleCallingContext
const* mcc) {
220 ModuleCallingContext
const* imcc = mcc;
222 std::ostringstream iost;
223 iost <<
"Calling method for unscheduled module "
225 << imcc->moduleDescription()->moduleLabel() <<
"'";
227 imcc = imcc->moduleCallingContext();
230 std::ostringstream iost;
231 iost <<
"Calling method for unscheduled module "
232 << imcc->moduleDescription()->moduleName() <<
"/'"
233 << imcc->moduleDescription()->moduleLabel() <<
"' (probably inside some kind of mixing module)";
235 imcc = imcc->internalContext()->moduleCallingContext();
238 std::ostringstream iost;
239 iost <<
"Calling method for unscheduled module "
240 << imcc->moduleDescription()->moduleName() <<
"/'"
241 << imcc->moduleDescription()->moduleLabel() <<
"'";
243 imcc = imcc->moduleCallingContext();
245 std::ostringstream ost;
247 ost <<
"Calling event method";
254 ost <<
"Calling unknown function";
256 ost <<
" for module " << imcc->moduleDescription()->moduleName() <<
"/'" << imcc->moduleDescription()->moduleLabel() <<
"'";
261 ost <<
"Running path '";
262 ost << imcc->placeInPathContext()->pathContext()->pathName() <<
"'";
266 ost <<
"Processing ";
267 ost << principal.id();
272 namespace workerhelper {
278 return iWorker->
implDo(ep,es, mcc);
350 template <
typename T>
356 typename T::Context
const* context) {
369 case Pass:
return true;
370 case Fail:
return false;
386 for(
auto const& item : items) {
388 bool skipCurrentProcess = item.skipCurrentProcess();
static bool call(Worker *iWorker, StreamID id, LuminosityBlockPrincipal &ep, EventSetup const &es, ModuleCallingContext const *mcc)
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
boost::shared_ptr< ActivityRegistry > actReg_
static bool call(Worker *iWorker, StreamID, EventPrincipal &ep, EventSetup const &es, ModuleCallingContext const *mcc)
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
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, LuminosityBlockPrincipal &ep, EventSetup const &es, ModuleCallingContext const *mcc)
static bool call(Worker *iWorker, StreamID id, LuminosityBlockPrincipal &ep, EventSetup const &es, ModuleCallingContext const *mcc)
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
static bool call(Worker *iWorker, StreamID, LuminosityBlockPrincipal &ep, EventSetup const &es, ModuleCallingContext const *mcc)
void stdToEDM(std::exception const &e)
PathContext const * pathContext() const
ModuleDescription const * descPtr() const
static bool call(Worker *iWorker, StreamID id, RunPrincipal &ep, EventSetup const &es, ModuleCallingContext const *mcc)
ModuleDescription const * moduleDescription() const
void printCmsExceptionWarning(char const *behavior, cms::Exception const &e, edm::JobReport *jobRep=0, int rc=-1)
Worker(ModuleDescription const &iMD, ExceptionToActionTable const *iActions)
static bool call(Worker *iWorker, StreamID, RunPrincipal &ep, EventSetup const &es, ModuleCallingContext const *mcc)
static bool call(Worker *iWorker, StreamID id, RunPrincipal &ep, EventSetup const &es, ModuleCallingContext const *mcc)
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
void postDoEvent(EventPrincipal &)
void charPtrToEDM(char const *c)
void stringToEDM(std::string &s)
boost::shared_ptr< cms::Exception > cached_exception_
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)
RunStopwatch::StopwatchPointer stopwatch_
static bool call(Worker *iWorker, StreamID, RunPrincipal &ep, EventSetup const &es, ModuleCallingContext const *mcc)
virtual bool implDoEnd(RunPrincipal &rp, EventSetup const &c, ModuleCallingContext const *mcc)=0
virtual void implRespondToOpenInputFile(FileBlock const &fb)=0
PlaceInPathContext const * placeInPathContext() const
virtual bool implDoStreamEnd(StreamID id, RunPrincipal &rp, EventSetup const &c, ModuleCallingContext const *mcc)=0