CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
edm::UnscheduledProductResolver Class Reference

#include <ProductResolvers.h>

Inheritance diagram for edm::UnscheduledProductResolver:
edm::ProducedProductResolver edm::DataManagingProductResolver edm::ProductResolverBase

Public Member Functions

virtual void setupUnscheduled (UnscheduledConfigurator const &) overridefinal
 
 UnscheduledProductResolver (std::shared_ptr< BranchDescription const > bd)
 
- Public Member Functions inherited from edm::ProducedProductResolver
 ProducedProductResolver (std::shared_ptr< BranchDescription const > bd, ProductStatus iDefaultStatus)
 
virtual void resetFailedFromThisProcess () override
 
- Public Member Functions inherited from edm::DataManagingProductResolver
virtual void connectTo (ProductResolverBase const &, Principal const *) overridefinal
 
 DataManagingProductResolver (std::shared_ptr< BranchDescription const > bd, ProductStatus iDefaultStatus)
 
void resetStatus ()
 
template<bool callResolver, typename FUNC >
ProductResolverBase::Resolution resolveProductImpl (FUNC resolver) const
 
- Public Member Functions inherited from edm::ProductResolverBase
BranchDescription const & branchDescription () const
 
std::string const & moduleLabel () const
 
ProductResolverBaseoperator= (ProductResolverBase const &)=delete
 
void prefetchAsync (WaitingTask *waitTask, Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
 
std::string const & processName () const
 
ProductID const & productID () const
 
std::string const & productInstanceName () const
 
ProductProvenance const * productProvenancePtr () const
 
bool productResolved () const
 
 ProductResolverBase ()
 
 ProductResolverBase (ProductResolverBase const &)=delete
 
TypeID productType () const
 
bool productUnavailable () const
 
bool productWasDeleted () const
 
bool productWasFetchedAndIsValid (bool iSkipCurrentProcess) const
 
Provenance const * provenance () const
 
bool provenanceAvailable () const
 
void putOrMergeProduct (std::unique_ptr< WrapperBase > edp) const
 
void putProduct (std::unique_ptr< WrapperBase > edp) const
 
void resetBranchDescription (std::shared_ptr< BranchDescription const > bd)
 
void resetProductData ()
 
std::string const & resolvedModuleLabel () const
 
Resolution resolveProduct (Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
 
void retrieveAndMerge (Principal const &principal) const
 
void setProcessHistory (ProcessHistory const &ph)
 
void setProvenance (ProductProvenanceRetriever const *provRetriever, ProcessHistory const &ph, ProductID const &pid)
 
bool singleProduct () const
 
StableProvenance const * stableProvenance () const
 
void unsafe_deleteProduct () const
 
bool unscheduledWasNotRun () const
 
void write (std::ostream &os) const
 
virtual ~ProductResolverBase ()
 

Private Member Functions

virtual void prefetchAsync_ (WaitingTask *waitTask, Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const override
 
virtual void resetProductData_ (bool deleteEarly) override
 
virtual Resolution resolveProduct_ (Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const override
 
virtual bool unscheduledWasNotRun_ () const override
 

Private Attributes

UnscheduledAuxiliary const * aux_
 
std::atomic< bool > prefetchRequested_
 
WaitingTaskList waitingTasks_
 
Workerworker_
 

Additional Inherited Members

- Public Types inherited from edm::DataManagingProductResolver
enum  ProductStatus {
  ProductStatus::ProductSet, ProductStatus::NotPut, ProductStatus::ResolveFailed, ProductStatus::ResolveNotRun,
  ProductStatus::ProductDeleted
}
 
- Protected Member Functions inherited from edm::ProducedProductResolver
virtual void putProduct_ (std::unique_ptr< WrapperBase > edp) const override
 
- Protected Member Functions inherited from edm::DataManagingProductResolver
ProductStatus defaultStatus () const
 
template<bool callResolver, typename FUNC >
Resolution resolveProductImpl (FUNC resolver) const
 
void setFailedStatus () const
 
void setProduct (std::unique_ptr< WrapperBase > edp) const
 
ProductStatus status () const
 

Detailed Description

Definition at line 173 of file ProductResolvers.h.

Constructor & Destructor Documentation

edm::UnscheduledProductResolver::UnscheduledProductResolver ( std::shared_ptr< BranchDescription const >  bd)
inlineexplicit

Definition at line 175 of file ProductResolvers.h.

175  :
177  aux_(nullptr),
178  prefetchRequested_(false){}
ProducedProductResolver(std::shared_ptr< BranchDescription const > bd, ProductStatus iDefaultStatus)
UnscheduledAuxiliary const * aux_
std::atomic< bool > prefetchRequested_

Member Function Documentation

void edm::UnscheduledProductResolver::prefetchAsync_ ( WaitingTask waitTask,
Principal const &  principal,
bool  skipCurrentProcess,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const
overrideprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 377 of file ProductResolvers.cc.

References edm::WaitingTaskList::add(), aux_, edmStreamStallGrapher::const, edm::WaitingTaskList::doneWaiting(), edm::Worker::doWorkAsync(), event(), edm::UnscheduledAuxiliary::eventSetup(), edm::ModuleCallingContext::getStreamContext(), edm::make_waiting_task(), prefetchRequested_, cmsRelvalreport::principal(), t, waitingTasks_, and worker_.

382  {
383  if(skipCurrentProcess) { return; }
384  waitingTasks_.add(waitTask);
385  bool expected = false;
386  if(prefetchRequested_.compare_exchange_strong(expected, true)) {
387 
388  //Have to create a new task which will make sure the state for UnscheduledProductResolver
389  // is properly set after the module has run
390  auto t = make_waiting_task(tbb::task::allocate_root(),
391  [this,&principal, skipCurrentProcess,sra,mcc](std::exception_ptr const* iPtr)
392  {
393  //The exception is being rethrown because resolveProductImpl sets the ProductResolver to a failed
394  // state for the case where an exception occurs during the call to the function.
395  try {
396  resolveProductImpl<true>([iPtr]() {
397  if ( iPtr) {
398  std::rethrow_exception(*iPtr);
399  }
400  });
401  } catch(...) {
402  waitingTasks_.doneWaiting(std::current_exception());
403  return;
404  }
405  waitingTasks_.doneWaiting(nullptr);
406  } );
407  auto const& event = static_cast<EventPrincipal const&>(principal);
408  ParentContext parentContext(mcc);
409 
410  worker_->doWorkAsync<OccurrenceTraits<EventPrincipal, BranchActionStreamBegin> >(t,
411  event,
412  *(aux_->eventSetup()),
413  event.streamID(),
414  parentContext,
415  mcc->getStreamContext());
416  }
417  }
void add(WaitingTask *)
Adds task to the waiting list.
EventSetup const * eventSetup() const
UnscheduledAuxiliary const * aux_
void doneWaiting(std::exception_ptr iPtr)
Signals that the resource is now available and tasks should be spawned.
std::atomic< bool > prefetchRequested_
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
FunctorWaitingTask< F > * make_waiting_task(ALLOC &&iAlloc, F f)
Definition: WaitingTask.h:90
void doWorkAsync(WaitingTask *task, typename T::MyPrincipal const &, EventSetup const &c, StreamID stream, ParentContext const &parentContext, typename T::Context const *context)
Definition: Worker.h:602
void edm::UnscheduledProductResolver::resetProductData_ ( bool  deleteEarly)
overrideprivatevirtual

Reimplemented from edm::DataManagingProductResolver.

Definition at line 420 of file ProductResolvers.cc.

References prefetchRequested_, edm::WaitingTaskList::reset(), edm::DataManagingProductResolver::resetProductData_(), and waitingTasks_.

420  {
421  prefetchRequested_ = false;
424  }
virtual void resetProductData_(bool deleteEarly) override
void reset()
Resets access to the resource so that added tasks will wait.
std::atomic< bool > prefetchRequested_
ProductResolverBase::Resolution edm::UnscheduledProductResolver::resolveProduct_ ( Principal const &  principal,
bool  skipCurrentProcess,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const
overrideprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 333 of file ProductResolvers.cc.

References cms::Exception::addContext(), assert(), aux_, edmStreamStallGrapher::const, edm::signalslot::Signal< T >::emit(), event(), edm::UnscheduledAuxiliary::eventSetup(), edm::ModuleCallingContext::getStreamContext(), edm::make_sentry(), edm::UnscheduledAuxiliary::postModuleDelayedGetSignal_, edm::UnscheduledAuxiliary::preModuleDelayedGetSignal_, cmsRelvalreport::principal(), Resolution, and worker_.

336  {
337  if (!skipCurrentProcess and worker_) {
338  return resolveProductImpl<true>(
339  [&principal,this,sra,mcc]() {
340  try {
341  auto const& event = static_cast<EventPrincipal const&>(principal);
342  ParentContext parentContext(mcc);
343  aux_->preModuleDelayedGetSignal_.emit(*(mcc->getStreamContext()),*mcc);
344 
345  auto workCall = [this,&event,&parentContext,mcc] () {
346  auto sentry( make_sentry(mcc,[this](ModuleCallingContext const* iContext){aux_->postModuleDelayedGetSignal_.emit(*(iContext->getStreamContext()), *iContext); }));
347 
348  worker_->doWork<OccurrenceTraits<EventPrincipal, BranchActionStreamBegin> >(
349  event,
350  *(aux_->eventSetup()),
351  event.streamID(),
352  parentContext,
353  mcc->getStreamContext());
354  };
355 
356  if (sra) {
357  assert(false);
358  } else {
359  workCall();
360  }
361 
362  }
363  catch (cms::Exception & ex) {
364  std::ostringstream ost;
365  ost << "Calling produce method for unscheduled module "
366  << worker_->description().moduleName() << "/'"
367  << worker_->description().moduleLabel() << "'";
368  ex.addContext(ost.str());
369  throw;
370  }
371  });
372  }
373  return Resolution(nullptr);
374  }
std::unique_ptr< T, F > make_sentry(T *iObject, F iFunc)
NOTE: if iObject is null, then iFunc will not be called.
Definition: make_sentry.h:29
assert(m_qm.get())
EventSetup const * eventSetup() const
UnscheduledAuxiliary const * aux_
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void addContext(std::string const &context)
Definition: Exception.cc:227
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> preModuleDelayedGetSignal_
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> postModuleDelayedGetSignal_
void emit(Args &&...args) const
Definition: Signal.h:47
void edm::UnscheduledProductResolver::setupUnscheduled ( UnscheduledConfigurator const &  iConfigure)
finaloverridevirtual

Reimplemented from edm::ProductResolverBase.

Definition at line 325 of file ProductResolvers.cc.

References assert(), aux_, edm::UnscheduledConfigurator::auxiliary(), edm::ProductResolverBase::branchDescription(), edm::UnscheduledConfigurator::findWorker(), edm::ProductResolverBase::moduleLabel(), and worker_.

325  {
326  aux_ = iConfigure.auxiliary();
327  worker_ = iConfigure.findWorker(branchDescription().moduleLabel());
328  assert(worker_ != nullptr);
329 
330  }
assert(m_qm.get())
UnscheduledAuxiliary const * aux_
BranchDescription const & branchDescription() const
std::string const & moduleLabel() const
virtual bool edm::UnscheduledProductResolver::unscheduledWasNotRun_ ( ) const
inlineoverrideprivatevirtual

Member Data Documentation

UnscheduledAuxiliary const* edm::UnscheduledProductResolver::aux_
private

Definition at line 197 of file ProductResolvers.h.

Referenced by prefetchAsync_(), resolveProduct_(), and setupUnscheduled().

std::atomic<bool> edm::UnscheduledProductResolver::prefetchRequested_
mutableprivate

Definition at line 199 of file ProductResolvers.h.

Referenced by prefetchAsync_(), and resetProductData_().

WaitingTaskList edm::UnscheduledProductResolver::waitingTasks_
mutableprivate

Definition at line 196 of file ProductResolvers.h.

Referenced by prefetchAsync_(), and resetProductData_().

Worker* edm::UnscheduledProductResolver::worker_
private

Definition at line 198 of file ProductResolvers.h.

Referenced by prefetchAsync_(), resolveProduct_(), and setupUnscheduled().