CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
edm::SwitchProducerProductResolver Class Reference

#include <ProductResolvers.h>

Inheritance diagram for edm::SwitchProducerProductResolver:
edm::SwitchBaseProductResolver edm::DataManagingOrAliasProductResolver edm::ProductResolverBase

Public Member Functions

 SwitchProducerProductResolver (std::shared_ptr< BranchDescription const > bd, DataManagingOrAliasProductResolver &realProduct)
 
- Public Member Functions inherited from edm::SwitchBaseProductResolver
void connectTo (ProductResolverBase const &iOther, Principal const *iParentPrincipal) final
 
void setupUnscheduled (UnscheduledConfigurator const &iConfigure) final
 
 SwitchBaseProductResolver (std::shared_ptr< BranchDescription const > bd, DataManagingOrAliasProductResolver &realProduct)
 
- 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 (WaitingTask *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 putOrMergeProduct (std::unique_ptr< WrapperBase > edp, MergeableRunProductMetadata const *mergeableRunProductMetadata=nullptr) 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, 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 ()
 

Private Member Functions

void prefetchAsync_ (WaitingTask *waitTask, Principal const &principal, bool skipCurrentProcess, ServiceToken const &token, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const final
 
bool productUnavailable_ () const final
 
void putProduct_ (std::unique_ptr< WrapperBase > edp) const final
 
void resetProductData_ (bool deleteEarly) final
 
Resolution resolveProduct_ (Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const final
 
bool unscheduledWasNotRun_ () const final
 

Private Attributes

ProductStatus status_
 

Static Private Attributes

constexpr static const ProductStatus defaultStatus_ = ProductStatus::NotPut
 

Additional Inherited Members

- Public Types inherited from edm::SwitchBaseProductResolver
using ProductStatus = DataManagingProductResolver::ProductStatus
 
- Protected Member Functions inherited from edm::SwitchBaseProductResolver
std::atomic< bool > & prefetchRequested () const
 
DataManagingOrAliasProductResolver const & realProduct () const
 
Resolution resolveProductImpl (Resolution) const
 
void unsafe_setWrapperAndProvenance () const
 
WaitingTaskListwaitingTasks () const
 
Workerworker () const
 

Detailed Description

Definition at line 317 of file ProductResolvers.h.

Constructor & Destructor Documentation

◆ SwitchProducerProductResolver()

edm::SwitchProducerProductResolver::SwitchProducerProductResolver ( std::shared_ptr< BranchDescription const >  bd,
DataManagingOrAliasProductResolver realProduct 
)

Member Function Documentation

◆ prefetchAsync_()

void edm::SwitchProducerProductResolver::prefetchAsync_ ( WaitingTask waitTask,
Principal const &  principal,
bool  skipCurrentProcess,
ServiceToken const &  token,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const
finalprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 693 of file ProductResolvers.cc.

698  {
699  if (skipCurrentProcess) {
700  return;
701  }
702  if (branchDescription().availableOnlyAtEndTransition() and mcc and not mcc->parent().isAtEndTransition()) {
703  return;
704  }
705 
706  //need to try changing prefetchRequested before adding to waitingTasks
707  bool expected = false;
708  bool doPrefetchRequested = prefetchRequested().compare_exchange_strong(expected, true);
709  waitingTasks().add(waitTask);
710 
711  if (doPrefetchRequested) {
712  //using a waiting task to do a callback guarantees that
713  // the waitingTasks() list will be released from waiting even
714  // if the module does not put this data product or the
715  // module has an exception while running
716  auto waiting = make_waiting_task(tbb::task::allocate_root(), [this](std::exception_ptr const* iException) {
717  if (nullptr != iException) {
718  waitingTasks().doneWaiting(*iException);
719  } else {
721  waitingTasks().doneWaiting(std::exception_ptr());
722  }
723  });
724  worker()->callWhenDoneAsync(waiting);
725  }
726  }

References edm::WaitingTaskList::add(), edm::ProductResolverBase::branchDescription(), edm::Worker::callWhenDoneAsync(), edm::WaitingTaskList::doneWaiting(), edm::ParentContext::isAtEndTransition(), edm::make_waiting_task(), edm::ModuleCallingContext::parent(), edm::SwitchBaseProductResolver::prefetchRequested(), edm::SwitchBaseProductResolver::unsafe_setWrapperAndProvenance(), edm::SwitchBaseProductResolver::waitingTasks(), and edm::SwitchBaseProductResolver::worker().

◆ productUnavailable_()

bool edm::SwitchProducerProductResolver::productUnavailable_ ( ) const
finalprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 744 of file ProductResolvers.cc.

744  {
745  // if produce() was run (ResolveFailed), ask from the real resolver
747  return realProduct().productUnavailable();
748  }
749  return true;
750  }

References edm::ProductResolverBase::productUnavailable(), edm::SwitchBaseProductResolver::realProduct(), edm::DataManagingProductResolver::ResolveFailed, and status_.

◆ putProduct_()

void edm::SwitchProducerProductResolver::putProduct_ ( std::unique_ptr< WrapperBase edp) const
finalprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 728 of file ProductResolvers.cc.

728  {
729  if (status_ != defaultStatus_) {
731  << "Attempt to insert more than one product for a branch " << branchDescription().branchName()
732  << "This makes no sense for SwitchProducerProductResolver.\nContact a Framework developer";
733  }
734  // Let's use ResolveFailed to signal that produce() was called, as
735  // there is no real product in this resolver
737  bool expected = false;
738  if (prefetchRequested().compare_exchange_strong(expected, true)) {
740  waitingTasks().doneWaiting(std::exception_ptr());
741  }
742  }

References edm::ProductResolverBase::branchDescription(), edm::BranchDescription::branchName(), defaultStatus_, edm::WaitingTaskList::doneWaiting(), Exception, edm::errors::InsertFailure, edm::SwitchBaseProductResolver::prefetchRequested(), edm::DataManagingProductResolver::ResolveFailed, status_, edm::SwitchBaseProductResolver::unsafe_setWrapperAndProvenance(), and edm::SwitchBaseProductResolver::waitingTasks().

◆ resetProductData_()

void edm::SwitchProducerProductResolver::resetProductData_ ( bool  deleteEarly)
finalprivatevirtual

Reimplemented from edm::SwitchBaseProductResolver.

Definition at line 752 of file ProductResolvers.cc.

752  {
754  if (not deleteEarly) {
756  }
757  }

References defaultStatus_, edm::SwitchBaseProductResolver::resetProductData_(), and status_.

◆ resolveProduct_()

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

◆ unscheduledWasNotRun_()

bool edm::SwitchProducerProductResolver::unscheduledWasNotRun_ ( ) const
inlinefinalprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 334 of file ProductResolvers.h.

334 { return false; }

Member Data Documentation

◆ defaultStatus_

constexpr static const ProductStatus edm::SwitchProducerProductResolver::defaultStatus_ = ProductStatus::NotPut
staticconstexprprivate

Definition at line 338 of file ProductResolvers.h.

Referenced by putProduct_(), and resetProductData_().

◆ status_

ProductStatus edm::SwitchProducerProductResolver::status_
mutableprivate
edm::WaitingTaskList::add
void add(WaitingTask *)
Adds task to the waiting list.
Definition: WaitingTaskList.cc:89
edm::SwitchBaseProductResolver::worker
Worker * worker() const
Definition: ProductResolvers.h:276
edm::SwitchProducerProductResolver::status_
ProductStatus status_
Definition: ProductResolvers.h:343
edm::SwitchBaseProductResolver::waitingTasks
WaitingTaskList & waitingTasks() const
Definition: ProductResolvers.h:275
edm::ProductResolverBase::productUnavailable
bool productUnavailable() const
Definition: ProductResolverBase.h:87
edm::Worker::callWhenDoneAsync
void callWhenDoneAsync(WaitingTask *task)
Definition: Worker.h:167
edm::SwitchBaseProductResolver::resolveProductImpl
Resolution resolveProductImpl(Resolution) const
Definition: ProductResolvers.cc:632
edm::WaitingTaskList::doneWaiting
void doneWaiting(std::exception_ptr iPtr)
Signals that the resource is now available and tasks should be spawned.
Definition: WaitingTaskList.cc:169
edm::errors::InsertFailure
Definition: EDMException.h:35
edm::SwitchBaseProductResolver::realProduct
DataManagingOrAliasProductResolver const & realProduct() const
Definition: ProductResolvers.h:277
edm::ProductResolverBase::resolveProduct
Resolution resolveProduct(Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: ProductResolverBase.h:60
edm::make_waiting_task
FunctorWaitingTask< F > * make_waiting_task(ALLOC &&iAlloc, F f)
Definition: WaitingTask.h:87
Resolution
Definition: trackSplitPlot.h:33
edm::SwitchBaseProductResolver::resetProductData_
void resetProductData_(bool deleteEarly) override
Definition: ProductResolvers.cc:663
edm::BranchDescription::branchName
std::string const & branchName() const
Definition: BranchDescription.h:119
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::ProductResolverBase::branchDescription
BranchDescription const & branchDescription() const
Definition: ProductResolverBase.h:110
Exception
Definition: hltDiff.cc:246
edm::SwitchBaseProductResolver::prefetchRequested
std::atomic< bool > & prefetchRequested() const
Definition: ProductResolvers.h:278
edm::SwitchProducerProductResolver::defaultStatus_
constexpr static const ProductStatus defaultStatus_
Definition: ProductResolvers.h:338
edm::SwitchBaseProductResolver::unsafe_setWrapperAndProvenance
void unsafe_setWrapperAndProvenance() const
Definition: ProductResolvers.cc:672
edm::DataManagingProductResolver::ProductStatus::ResolveFailed
edm::SwitchBaseProductResolver::SwitchBaseProductResolver
SwitchBaseProductResolver(std::shared_ptr< BranchDescription const > bd, DataManagingOrAliasProductResolver &realProduct)
Definition: ProductResolvers.cc:612