CMS 3D CMS Logo

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

#include <ProductResolvers.h>

Inheritance diagram for edm::PuttableProductResolver:
edm::ProducedProductResolver edm::DataManagingProductResolver edm::ProductPutterBase edm::DataManagingOrAliasProductResolver edm::ProductResolverBase

Public Member Functions

 PuttableProductResolver (std::shared_ptr< BranchDescription const > bd)
 
void setupUnscheduled (UnscheduledConfigurator const &) final
 
- 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 ()
 
template<bool callResolver, typename FUNC >
ProductResolverBase::Resolution resolveProductImpl (FUNC resolver) const
 
- 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 putProduct (std::unique_ptr< WrapperBase > edp) 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

WaitingTaskList m_waitingTasks
 
std::atomic< bool > prefetchRequested_
 
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::DataManagingProductResolver
void checkType (WrapperBase const &prod) const
 
ProductStatus defaultStatus () const
 
ProductData const & getProductData () const final
 
template<bool callResolver, typename FUNC >
Resolution resolveProductImpl (FUNC resolver) const
 
void setFailedStatus () const
 
void setMergeableRunProductMetadataInProductData (MergeableRunProductMetadata const *)
 
void setProduct (std::unique_ptr< WrapperBase > edp) const
 
void setProduct (std::shared_ptr< WrapperBase > edp) const
 
ProductStatus status () const
 

Detailed Description

Definition at line 201 of file ProductResolvers.h.

Constructor & Destructor Documentation

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

Definition at line 203 of file ProductResolvers.h.

ProducedProductResolver(std::shared_ptr< BranchDescription const > bd, ProductStatus iDefaultStatus)
std::atomic< bool > prefetchRequested_

Member Function Documentation

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

Implements edm::ProductResolverBase.

Definition at line 390 of file ProductResolvers.cc.

References edm::WaitingTaskList::add(), edm::BranchDescription::availableOnlyAtEndTransition(), edm::ProductResolverBase::branchDescription(), edm::Worker::callWhenDoneAsync(), edm::WaitingTaskList::doneWaiting(), edm::ParentContext::globalContext(), edm::WaitingTaskHolder::group(), edm::InProcess, edm::ParentContext::isAtEndTransition(), edm::GlobalContext::kAccessInputProcessBlock, m_waitingTasks, edm::make_waiting_task(), edm::ModuleCallingContext::parent(), prefetchRequested_, edm::GlobalContext::transition(), and worker_.

395  {
396  if (not skipCurrentProcess) {
397  if (branchDescription().branchType() == InProcess &&
398  mcc->parent().globalContext()->transition() == GlobalContext::Transition::kAccessInputProcessBlock) {
399  // This is an accessInputProcessBlock transition
400  // We cannot access produced products in those transitions
401  // except for in SubProcesses where they should have already run.
402  return;
403  }
405  if (not mcc->parent().isAtEndTransition()) {
406  return;
407  }
408  }
409 
410  //Need to try modifying prefetchRequested_ before adding to m_waitingTasks
411  bool expected = false;
412  bool prefetchRequested = prefetchRequested_.compare_exchange_strong(expected, true);
413  m_waitingTasks.add(waitTask);
414 
415  if (worker_ and prefetchRequested) {
416  //using a waiting task to do a callback guarantees that
417  // the m_waitingTasks list will be released from waiting even
418  // if the module does not put this data product or the
419  // module has an exception while running
420 
421  auto waiting = make_waiting_task([this](std::exception_ptr const* iException) {
422  if (nullptr != iException) {
423  m_waitingTasks.doneWaiting(*iException);
424  } else {
425  m_waitingTasks.doneWaiting(std::exception_ptr());
426  }
427  });
428  worker_->callWhenDoneAsync(WaitingTaskHolder(*waitTask.group(), waiting));
429  }
430  }
431  }
std::atomic< bool > prefetchRequested_
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:101
void callWhenDoneAsync(WaitingTaskHolder task)
Definition: Worker.h:167
BranchDescription const & branchDescription() const
bool availableOnlyAtEndTransition() const
void edm::PuttableProductResolver::putProduct ( std::unique_ptr< WrapperBase edp) const
overrideprivatevirtual

Reimplemented from edm::ProducedProductResolver.

Definition at line 433 of file ProductResolvers.cc.

References edm::WaitingTaskList::doneWaiting(), m_waitingTasks, eostools::move(), prefetchRequested_, and edm::ProducedProductResolver::putProduct().

433  {
435  bool expected = false;
436  if (prefetchRequested_.compare_exchange_strong(expected, true)) {
437  m_waitingTasks.doneWaiting(std::exception_ptr());
438  }
439  }
std::atomic< bool > prefetchRequested_
void doneWaiting(std::exception_ptr iPtr)
Signals that the resource is now available and tasks should be spawned.
def move
Definition: eostools.py:511
void putProduct(std::unique_ptr< WrapperBase > edp) const override
void edm::PuttableProductResolver::resetProductData_ ( bool  deleteEarly)
overrideprivatevirtual

Reimplemented from edm::DataManagingProductResolver.

Definition at line 441 of file ProductResolvers.cc.

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

441  {
442  if (not deleteEarly) {
443  prefetchRequested_ = false;
445  }
447  }
void resetProductData_(bool deleteEarly) override
std::atomic< bool > prefetchRequested_
void reset()
Resets access to the resource so that added tasks will wait.
ProductResolverBase::Resolution edm::PuttableProductResolver::resolveProduct_ ( Principal const &  principal,
bool  skipCurrentProcess,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const
overrideprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 379 of file ProductResolvers.cc.

References Resolution.

382  {
383  if (!skipCurrentProcess) {
384  //'false' means never call the lambda function
385  return resolveProductImpl<false>([]() { return; });
386  }
387  return Resolution(nullptr);
388  }
void edm::PuttableProductResolver::setupUnscheduled ( UnscheduledConfigurator const &  iConfigure)
finalvirtual

Reimplemented from edm::ProductResolverBase.

Definition at line 449 of file ProductResolvers.cc.

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

449  {
450  worker_ = iConfigure.findWorker(branchDescription().moduleLabel());
451  }
BranchDescription const & branchDescription() const
std::string const & moduleLabel() const
bool edm::PuttableProductResolver::unscheduledWasNotRun_ ( ) const
inlineoverrideprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 219 of file ProductResolvers.h.

219 { return false; }

Member Data Documentation

WaitingTaskList edm::PuttableProductResolver::m_waitingTasks
mutableprivate

Definition at line 224 of file ProductResolvers.h.

Referenced by prefetchAsync_(), putProduct(), and resetProductData_().

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

Definition at line 226 of file ProductResolvers.h.

Referenced by prefetchAsync_(), putProduct(), and resetProductData_().

Worker* edm::PuttableProductResolver::worker_
private

Definition at line 225 of file ProductResolvers.h.

Referenced by prefetchAsync_(), and setupUnscheduled().