CMS 3D CMS Logo

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::ProductPutterBase edm::DataManagingOrAliasProductResolver edm::ProductResolverBase

Public Member Functions

void setupUnscheduled (UnscheduledConfigurator const &) final
 
 UnscheduledProductResolver (std::shared_ptr< BranchDescription const > bd)
 
- Public Member Functions inherited from edm::ProducedProductResolver
 ProducedProductResolver (std::shared_ptr< BranchDescription const > bd, ProductStatus iDefaultStatus)
 
- Public Member Functions inherited from edm::DataManagingProductResolver
void connectTo (ProductResolverBase const &, Principal const *) final
 
 DataManagingProductResolver (std::shared_ptr< BranchDescription const > bd, ProductStatus iDefaultStatus)
 
void resetStatus ()
 
- Public Member Functions inherited from edm::DataManagingOrAliasProductResolver
 DataManagingOrAliasProductResolver ()
 
- Public Member Functions inherited from edm::ProductResolverBase
BranchDescription const & branchDescription () const
 
std::string const & moduleLabel () const
 
ProductResolverBaseoperator= (ProductResolverBase const &)=delete
 
void prefetchAsync (WaitingTaskHolder waitTask, Principal const &principal, bool skipCurrentProcess, ServiceToken const &token, 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 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, MergeableRunProductMetadata const *mergeableRunProductMetadata) const
 
void setMergeableRunProductMetadata (MergeableRunProductMetadata const *mrpm)
 
void setProductID (ProductID const &pid)
 
void setProductProvenanceRetriever (ProductProvenanceRetriever const *provRetriever)
 
bool singleProduct () const
 
StableProvenance const * stableProvenance () const
 
void unsafe_deleteProduct () const
 
bool unscheduledWasNotRun () const
 
void write (std::ostream &os) const
 
virtual ~ProductResolverBase ()
 
- Public Member Functions inherited from edm::ProductPutterBase
 ProductPutterBase ()=default
 
virtual ~ProductPutterBase ()=default
 

Private Member Functions

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

Private Attributes

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

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
void putProduct (std::unique_ptr< WrapperBase > edp) const override
 
- Protected Member Functions inherited from edm::DataManagingProductResolver
void checkType (WrapperBase const &prod) const
 
ProductStatus defaultStatus () const
 
ProductData const & getProductData () const final
 
template<bool callResolver, typename FUNC >
ProductResolverBase::Resolution resolveProductImpl (FUNC resolver) const
 
template<bool callResolver, typename FUNC >
Resolution resolveProductImpl (FUNC resolver) const
 
void setFailedStatus () const
 
void setMergeableRunProductMetadataInProductData (MergeableRunProductMetadata const *)
 
void setProduct (std::shared_ptr< WrapperBase > edp) const
 
void setProduct (std::unique_ptr< WrapperBase > edp) const
 
ProductStatus status () const
 

Detailed Description

Definition at line 229 of file ProductResolvers.h.

Constructor & Destructor Documentation

◆ UnscheduledProductResolver()

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

Member Function Documentation

◆ prefetchAsync_()

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

Implements edm::ProductResolverBase.

Definition at line 452 of file ProductResolvers.cc.

457  {
458  if (skipCurrentProcess) {
459  return;
460  }
461  if (worker_ == nullptr) {
462  throw cms::Exception("LogicError") << "UnscheduledProductResolver::prefetchAsync_() called with null worker_. "
463  "This should not happen, please contact framework developers.";
464  }
465  //need to try changing prefetchRequested_ before adding to waitingTasks_
466  bool expected = false;
467  bool prefetchRequested = prefetchRequested_.compare_exchange_strong(expected, true);
468  waitingTasks_.add(waitTask);
469  if (prefetchRequested) {
470  //Have to create a new task which will make sure the state for UnscheduledProductResolver
471  // is properly set after the module has run
472  auto t = make_waiting_task([this](std::exception_ptr const* iPtr) {
473  //The exception is being rethrown because resolveProductImpl sets the ProductResolver to a failed
474  // state for the case where an exception occurs during the call to the function.
475  // Caught exception is propagated via WaitingTaskList
476  CMS_SA_ALLOW try {
477  resolveProductImpl<true>([iPtr]() {
478  if (iPtr) {
479  std::rethrow_exception(*iPtr);
480  }
481  });
482  } catch (...) {
483  waitingTasks_.doneWaiting(std::current_exception());
484  return;
485  }
486  waitingTasks_.doneWaiting(nullptr);
487  });
488 
489  ParentContext parentContext(mcc);
490  EventTransitionInfo const& info = aux_->eventTransitionInfo();
491  worker_->doWorkAsync<OccurrenceTraits<EventPrincipal, BranchActionStreamBegin> >(
492  WaitingTaskHolder(*waitTask.group(), t),
493  info,
494  token,
495  info.principal().streamID(),
496  parentContext,
497  mcc->getStreamContext());
498  }
499  }

References edm::WaitingTaskList::add(), aux_, CMS_SA_ALLOW, edm::WaitingTaskList::doneWaiting(), edm::Worker::doWorkAsync(), edm::UnscheduledAuxiliary::eventTransitionInfo(), Exception, edm::ModuleCallingContext::getStreamContext(), edm::WaitingTaskHolder::group(), info(), edm::make_waiting_task(), prefetchRequested_, submitPVValidationJobs::t, unpackBuffers-CaloStage2::token, waitingTasks_, and worker_.

◆ resetProductData_()

void edm::UnscheduledProductResolver::resetProductData_ ( bool  deleteEarly)
overrideprivatevirtual

Reimplemented from edm::DataManagingProductResolver.

Definition at line 501 of file ProductResolvers.cc.

501  {
502  if (not deleteEarly) {
503  prefetchRequested_ = false;
505  }
507  }

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

◆ resolveProduct_()

ProductResolverBase::Resolution edm::UnscheduledProductResolver::resolveProduct_ ( Principal const &  principal,
bool  skipCurrentProcess,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const
overrideprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 434 of file ProductResolvers.cc.

437  {
438  if (!skipCurrentProcess and worker_) {
439  return resolveProductImpl<true>([this]() {
441  ex << "Attempting to run unscheduled module without doing prefetching";
442  std::ostringstream ost;
443  ost << "Calling produce method for unscheduled module " << worker_->description()->moduleName() << "/'"
444  << worker_->description()->moduleLabel() << "'";
445  ex.addContext(ost.str());
446  throw ex;
447  });
448  }
449  return Resolution(nullptr);
450  }

References cms::Exception::addContext(), edm::Worker::description(), edm::ModuleDescription::moduleLabel(), edm::ModuleDescription::moduleName(), Resolution, edm::errors::UnimplementedFeature, and worker_.

◆ setupUnscheduled()

void edm::UnscheduledProductResolver::setupUnscheduled ( UnscheduledConfigurator const &  iConfigure)
finalvirtual

◆ unscheduledWasNotRun_()

bool edm::UnscheduledProductResolver::unscheduledWasNotRun_ ( ) const
inlineoverrideprivatevirtual

Member Data Documentation

◆ aux_

UnscheduledAuxiliary const* edm::UnscheduledProductResolver::aux_ = nullptr
private

Definition at line 252 of file ProductResolvers.h.

Referenced by prefetchAsync_(), and setupUnscheduled().

◆ prefetchRequested_

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

Definition at line 254 of file ProductResolvers.h.

Referenced by prefetchAsync_(), and resetProductData_().

◆ waitingTasks_

WaitingTaskList edm::UnscheduledProductResolver::waitingTasks_
mutableprivate

Definition at line 251 of file ProductResolvers.h.

Referenced by prefetchAsync_(), and resetProductData_().

◆ worker_

Worker* edm::UnscheduledProductResolver::worker_ = nullptr
private

Definition at line 253 of file ProductResolvers.h.

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

edm::ModuleDescription::moduleLabel
std::string const & moduleLabel() const
Definition: ModuleDescription.h:43
edm::ProducedProductResolver::ProducedProductResolver
ProducedProductResolver(std::shared_ptr< BranchDescription const > bd, ProductStatus iDefaultStatus)
Definition: ProductResolvers.h:189
edm::UnscheduledAuxiliary::eventTransitionInfo
EventTransitionInfo const & eventTransitionInfo() const
Definition: UnscheduledAuxiliary.h:36
deep_tau::DeepTauBase::BasicDiscriminator
BasicDiscriminator
Definition: DeepTauBase.h:115
edm::ModuleDescription::moduleName
std::string const & moduleName() const
Definition: ModuleDescription.h:42
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
CMS_SA_ALLOW
#define CMS_SA_ALLOW
Definition: thread_safety_macros.h:5
edm::Exception
Definition: EDMException.h:77
edm::WaitingTaskList::reset
void reset()
Resets access to the resource so that added tasks will wait.
Definition: WaitingTaskList.cc:53
edm::Worker::description
ModuleDescription const * description() const
Definition: Worker.h:188
edm::Worker::doWorkAsync
void doWorkAsync(WaitingTaskHolder, typename T::TransitionInfoType const &, ServiceToken const &, StreamID, ParentContext const &, typename T::Context const *)
Definition: Worker.h:933
edm::WaitingTaskList::doneWaiting
void doneWaiting(std::exception_ptr iPtr)
Signals that the resource is now available and tasks should be spawned.
Definition: WaitingTaskList.cc:212
WaitingTaskHolder
edm::UnscheduledProductResolver::waitingTasks_
WaitingTaskList waitingTasks_
Definition: ProductResolvers.h:251
edm::UnscheduledProductResolver::aux_
UnscheduledAuxiliary const * aux_
Definition: ProductResolvers.h:252
Resolution
Definition: trackSplitPlot.h:33
edm::make_waiting_task
FunctorWaitingTask< F > * make_waiting_task(F f)
Definition: WaitingTask.h:101
edm::DataManagingProductResolver::ProductStatus::ResolveNotRun
edm::ProductResolverBase::moduleLabel
std::string const & moduleLabel() const
Definition: ProductResolverBase.h:119
edm::DataManagingProductResolver::resetProductData_
void resetProductData_(bool deleteEarly) override
Definition: ProductResolvers.cc:599
edm::WaitingTaskList::add
void add(tbb::task_group *, WaitingTask *)
Adds task to the waiting list.
Definition: WaitingTaskList.cc:125
edm::DataManagingProductResolver::status
ProductStatus status() const
Definition: ProductResolvers.h:69
edm::ProductResolverBase::branchDescription
BranchDescription const & branchDescription() const
Definition: ProductResolverBase.h:110
edm::UnscheduledProductResolver::worker_
Worker * worker_
Definition: ProductResolvers.h:253
Exception
Definition: hltDiff.cc:245
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
edm::errors::UnimplementedFeature
Definition: EDMException.h:38
edm::UnscheduledProductResolver::prefetchRequested_
std::atomic< bool > prefetchRequested_
Definition: ProductResolvers.h:254
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316