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::ProductPutterBase 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 (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 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

static constexpr 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 390 of file ProductResolvers.h.

Constructor & Destructor Documentation

◆ SwitchProducerProductResolver()

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

Definition at line 766 of file ProductResolvers.cc.

SwitchBaseProductResolver(std::shared_ptr< BranchDescription const > bd, DataManagingOrAliasProductResolver &realProduct)
DataManagingOrAliasProductResolver const & realProduct() const
static constexpr const ProductStatus defaultStatus_
def move(src, dest)
Definition: eostools.py:511

Member Function Documentation

◆ prefetchAsync_()

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

Implements edm::ProductResolverBase.

Definition at line 780 of file ProductResolvers.cc.

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

785  {
786  if (skipCurrentProcess) {
787  return;
788  }
789  if (branchDescription().availableOnlyAtEndTransition() and mcc and not mcc->parent().isAtEndTransition()) {
790  return;
791  }
792 
793  //need to try changing prefetchRequested before adding to waitingTasks
794  bool expected = false;
795  bool doPrefetchRequested = prefetchRequested().compare_exchange_strong(expected, true);
796  waitingTasks().add(waitTask);
797 
798  if (doPrefetchRequested) {
799  //using a waiting task to do a callback guarantees that
800  // the waitingTasks() list will be released from waiting even
801  // if the module does not put this data product or the
802  // module has an exception while running
803  auto waiting = make_waiting_task([this](std::exception_ptr const* iException) {
804  if (nullptr != iException) {
805  waitingTasks().doneWaiting(*iException);
806  } else {
808  waitingTasks().doneWaiting(std::exception_ptr());
809  }
810  });
811  worker()->callWhenDoneAsync(WaitingTaskHolder(*waitTask.group(), waiting));
812  }
813  }
WaitingTaskList & waitingTasks() const
void doneWaiting(std::exception_ptr iPtr)
Signals that the resource is now available and tasks should be spawned.
void add(oneapi::tbb::task_group *, WaitingTask *)
Adds task to the waiting list.
FunctorWaitingTask< F > * make_waiting_task(F f)
Definition: WaitingTask.h:92
void callWhenDoneAsync(WaitingTaskHolder task)
Definition: Worker.h:177
BranchDescription const & branchDescription() const
std::atomic< bool > & prefetchRequested() const

◆ productUnavailable_()

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

Implements edm::ProductResolverBase.

Definition at line 831 of file ProductResolvers.cc.

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

831  {
832  // if produce() was run (ResolveFailed), ask from the real resolver
834  return realProduct().productUnavailable();
835  }
836  return true;
837  }
DataManagingOrAliasProductResolver const & realProduct() const

◆ putProduct()

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

Implements edm::ProductPutterBase.

Definition at line 815 of file ProductResolvers.cc.

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().

815  {
816  if (status_ != defaultStatus_) {
818  << "Attempt to insert more than one product for a branch " << branchDescription().branchName()
819  << "This makes no sense for SwitchProducerProductResolver.\nContact a Framework developer";
820  }
821  // Let's use ResolveFailed to signal that produce() was called, as
822  // there is no real product in this resolver
824  bool expected = false;
825  if (prefetchRequested().compare_exchange_strong(expected, true)) {
827  waitingTasks().doneWaiting(std::exception_ptr());
828  }
829  }
WaitingTaskList & waitingTasks() const
void doneWaiting(std::exception_ptr iPtr)
Signals that the resource is now available and tasks should be spawned.
std::string const & branchName() const
static constexpr const ProductStatus defaultStatus_
BranchDescription const & branchDescription() const
std::atomic< bool > & prefetchRequested() const

◆ resetProductData_()

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

Reimplemented from edm::SwitchBaseProductResolver.

Definition at line 839 of file ProductResolvers.cc.

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

839  {
841  if (not deleteEarly) {
843  }
844  }
void resetProductData_(bool deleteEarly) override
static constexpr const ProductStatus defaultStatus_

◆ resolveProduct_()

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

Implements edm::ProductResolverBase.

Definition at line 770 of file ProductResolvers.cc.

References edm::SwitchBaseProductResolver::realProduct(), Resolution, edm::DataManagingProductResolver::ResolveFailed, edm::ProductResolverBase::resolveProduct(), edm::SwitchBaseProductResolver::resolveProductImpl(), and status_.

773  {
775  return resolveProductImpl(realProduct().resolveProduct(principal, skipCurrentProcess, sra, mcc));
776  }
777  return Resolution(nullptr);
778  }
Resolution resolveProduct(Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
DataManagingOrAliasProductResolver const & realProduct() const
Resolution resolveProductImpl(Resolution) const

◆ unscheduledWasNotRun_()

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

Implements edm::ProductResolverBase.

Definition at line 407 of file ProductResolvers.h.

407 { return false; }

Member Data Documentation

◆ defaultStatus_

constexpr const ProductStatus edm::SwitchProducerProductResolver::defaultStatus_ = ProductStatus::NotPut
staticprivate

Definition at line 411 of file ProductResolvers.h.

Referenced by putProduct(), and resetProductData_().

◆ status_

ProductStatus edm::SwitchProducerProductResolver::status_
mutableprivate