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 ()
 
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 (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 setProcessHistory (ProcessHistory const &ph)
 
void setProvenance (ProductProvenanceRetriever const *provRetriever, ProcessHistory const &ph, ProductID const &pid)
 
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
 
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

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

Member Function Documentation

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 318 of file ProductResolvers.cc.

References edm::ProductResolverBase::branchDescription(), and edm::make_waiting_task().

323  {
324  if (not skipCurrentProcess) {
325  if (branchDescription().availableOnlyAtEndTransition() and mcc) {
326  if (not mcc->parent().isAtEndTransition()) {
327  return;
328  }
329  }
330  m_waitingTasks.add(waitTask);
331 
332  bool expected = false;
333  if (worker_ and prefetchRequested_.compare_exchange_strong(expected, true)) {
334  //using a waiting task to do a callback guarantees that
335  // the m_waitingTasks list will be released from waiting even
336  // if the module does not put this data product or the
337  // module has an exception while running
338 
339  auto waiting = make_waiting_task(tbb::task::allocate_root(), [this](std::exception_ptr const* iException) {
340  if (nullptr != iException) {
341  m_waitingTasks.doneWaiting(*iException);
342  } else {
343  m_waitingTasks.doneWaiting(std::exception_ptr());
344  }
345  });
346  worker_->callWhenDoneAsync(waiting);
347  }
348  }
349  }
void callWhenDoneAsync(WaitingTask *task)
Definition: Worker.h:167
void add(WaitingTask *)
Adds task to the waiting list.
std::atomic< bool > prefetchRequested_
void doneWaiting(std::exception_ptr iPtr)
Signals that the resource is now available and tasks should be spawned.
FunctorWaitingTask< F > * make_waiting_task(ALLOC &&iAlloc, F f)
Definition: WaitingTask.h:87
BranchDescription const & branchDescription() const
void edm::PuttableProductResolver::putProduct_ ( std::unique_ptr< WrapperBase edp) const
overrideprivatevirtual

Reimplemented from edm::ProducedProductResolver.

Definition at line 351 of file ProductResolvers.cc.

References eostools::move(), and edm::ProducedProductResolver::putProduct_().

351  {
353  bool expected = false;
354  if (prefetchRequested_.compare_exchange_strong(expected, true)) {
355  m_waitingTasks.doneWaiting(std::exception_ptr());
356  }
357  }
std::atomic< bool > prefetchRequested_
void putProduct_(std::unique_ptr< WrapperBase > edp) const override
void doneWaiting(std::exception_ptr iPtr)
Signals that the resource is now available and tasks should be spawned.
def move(src, dest)
Definition: eostools.py:511
void edm::PuttableProductResolver::resetProductData_ ( bool  deleteEarly)
overrideprivatevirtual

Reimplemented from edm::DataManagingProductResolver.

Definition at line 359 of file ProductResolvers.cc.

References edm::DataManagingProductResolver::resetProductData_().

359  {
362  prefetchRequested_ = false;
363  }
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 307 of file ProductResolvers.cc.

References Resolution.

310  {
311  if (!skipCurrentProcess) {
312  //'false' means never call the lambda function
313  return resolveProductImpl<false>([]() { return; });
314  }
315  return Resolution(nullptr);
316  }
void edm::PuttableProductResolver::setupUnscheduled ( UnscheduledConfigurator const &  iConfigure)
finalvirtual

Reimplemented from edm::ProductResolverBase.

Definition at line 365 of file ProductResolvers.cc.

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

365  {
366  worker_ = iConfigure.findWorker(branchDescription().moduleLabel());
367  }
BranchDescription const & branchDescription() const
std::string const & moduleLabel() const
bool edm::PuttableProductResolver::unscheduledWasNotRun_ ( ) const
inlineoverrideprivatevirtual

Member Data Documentation

WaitingTaskList edm::PuttableProductResolver::m_waitingTasks
mutableprivate

Definition at line 177 of file ProductResolvers.h.

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

Definition at line 179 of file ProductResolvers.h.

Worker* edm::PuttableProductResolver::worker_
private

Definition at line 178 of file ProductResolvers.h.