CMS 3D CMS Logo

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::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 ()
 
- 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 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
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::unique_ptr< WrapperBase > edp) const
 
ProductStatus status () const
 

Detailed Description

Definition at line 154 of file ProductResolvers.h.

Constructor & Destructor Documentation

◆ PuttableProductResolver()

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

Definition at line 156 of file ProductResolvers.h.

Member Function Documentation

◆ prefetchAsync_()

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

Implements edm::ProductResolverBase.

Definition at line 324 of file ProductResolvers.cc.

329  {
330  if (not skipCurrentProcess) {
331  if (branchDescription().availableOnlyAtEndTransition() and mcc) {
332  if (not mcc->parent().isAtEndTransition()) {
333  return;
334  }
335  }
336  //Need to try modifying prefetchRequested_ before adding to m_waitingTasks
337  bool expected = false;
338  bool prefetchRequested = prefetchRequested_.compare_exchange_strong(expected, true);
339  m_waitingTasks.add(waitTask);
340 
341  if (worker_ and prefetchRequested) {
342  //using a waiting task to do a callback guarantees that
343  // the m_waitingTasks list will be released from waiting even
344  // if the module does not put this data product or the
345  // module has an exception while running
346 
347  auto waiting = make_waiting_task(tbb::task::allocate_root(), [this](std::exception_ptr const* iException) {
348  if (nullptr != iException) {
349  m_waitingTasks.doneWaiting(*iException);
350  } else {
351  m_waitingTasks.doneWaiting(std::exception_ptr());
352  }
353  });
354  worker_->callWhenDoneAsync(waiting);
355  }
356  }
357  }

References edm::WaitingTaskList::add(), edm::ProductResolverBase::branchDescription(), edm::Worker::callWhenDoneAsync(), edm::WaitingTaskList::doneWaiting(), m_waitingTasks, edm::make_waiting_task(), prefetchRequested_, and worker_.

◆ putProduct_()

void edm::PuttableProductResolver::putProduct_ ( std::unique_ptr< WrapperBase edp) const
overrideprivatevirtual

Reimplemented from edm::ProducedProductResolver.

Definition at line 359 of file ProductResolvers.cc.

359  {
361  bool expected = false;
362  if (prefetchRequested_.compare_exchange_strong(expected, true)) {
363  m_waitingTasks.doneWaiting(std::exception_ptr());
364  }
365  }

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

◆ resetProductData_()

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

Reimplemented from edm::DataManagingProductResolver.

Definition at line 367 of file ProductResolvers.cc.

367  {
368  if (not deleteEarly) {
369  prefetchRequested_ = false;
371  }
373  }

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

◆ resolveProduct_()

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

Implements edm::ProductResolverBase.

Definition at line 313 of file ProductResolvers.cc.

316  {
317  if (!skipCurrentProcess) {
318  //'false' means never call the lambda function
319  return resolveProductImpl<false>([]() { return; });
320  }
321  return Resolution(nullptr);
322  }

References Resolution.

◆ setupUnscheduled()

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

◆ unscheduledWasNotRun_()

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

Implements edm::ProductResolverBase.

Definition at line 172 of file ProductResolvers.h.

172 { return false; }

Member Data Documentation

◆ m_waitingTasks

WaitingTaskList edm::PuttableProductResolver::m_waitingTasks
mutableprivate

Definition at line 177 of file ProductResolvers.h.

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

◆ prefetchRequested_

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

Definition at line 179 of file ProductResolvers.h.

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

◆ worker_

Worker* edm::PuttableProductResolver::worker_
private

Definition at line 178 of file ProductResolvers.h.

Referenced by prefetchAsync_(), and setupUnscheduled().

edm::ProducedProductResolver::putProduct_
void putProduct_(std::unique_ptr< WrapperBase > edp) const override
Definition: ProductResolvers.cc:471
edm::ProducedProductResolver::ProducedProductResolver
ProducedProductResolver(std::shared_ptr< BranchDescription const > bd, ProductStatus iDefaultStatus)
Definition: ProductResolvers.h:142
edm::WaitingTaskList::add
void add(WaitingTask *)
Adds task to the waiting list.
Definition: WaitingTaskList.cc:89
edm::DataManagingProductResolver::ProductStatus::NotPut
edm::WaitingTaskList::reset
void reset()
Resets access to the resource so that added tasks will wait.
Definition: WaitingTaskList.cc:51
edm::Worker::callWhenDoneAsync
void callWhenDoneAsync(WaitingTask *task)
Definition: Worker.h:167
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::make_waiting_task
FunctorWaitingTask< F > * make_waiting_task(ALLOC &&iAlloc, F f)
Definition: WaitingTask.h:87
Resolution
Definition: trackSplitPlot.h:33
edm::PuttableProductResolver::prefetchRequested_
std::atomic< bool > prefetchRequested_
Definition: ProductResolvers.h:179
edm::PuttableProductResolver::m_waitingTasks
WaitingTaskList m_waitingTasks
Definition: ProductResolvers.h:177
edm::ProductResolverBase::moduleLabel
std::string const & moduleLabel() const
Definition: ProductResolverBase.h:119
edm::DataManagingProductResolver::resetProductData_
void resetProductData_(bool deleteEarly) override
Definition: ProductResolvers.cc:571
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::ProductResolverBase::branchDescription
BranchDescription const & branchDescription() const
Definition: ProductResolverBase.h:110
edm::PuttableProductResolver::worker_
Worker * worker_
Definition: ProductResolvers.h:178