CMS 3D CMS Logo

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

#include <ProductResolvers.h>

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

Public Member Functions

void setupUnscheduled (UnscheduledConfigurator const &) final
 
 UnscheduledProductResolver (std::shared_ptr< BranchDescription const > bd)
 
- 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 resetProductData_ (bool deleteEarly) override
 
Resolution resolveProduct_ (Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const override
 
bool unscheduledWasNotRun_ () const override
 

Private Attributes

UnscheduledAuxiliary const * aux_ = nullptr
 
std::atomic< bool > prefetchRequested_ = false
 
WaitingTaskList waitingTasks_
 
Workerworker_ = nullptr
 

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::ProducedProductResolver
void putProduct (std::unique_ptr< WrapperBase > edp) const override
 
- 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 229 of file ProductResolvers.h.

Constructor & Destructor Documentation

◆ UnscheduledProductResolver()

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

Definition at line 231 of file ProductResolvers.h.

Member Function Documentation

◆ prefetchAsync_()

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

Implements edm::ProductResolverBase.

Definition at line 468 of file ProductResolvers.cc.

References edm::WaitingTaskList::add(), aux_, CMS_SA_ALLOW, edm::WaitingTaskList::doneWaiting(), edm::Worker::doWorkAsync(), edm::UnscheduledAuxiliary::eventTransitionInfo(), Exception, edm::ModuleCallingContext::getStreamContext(), edm::WaitingTaskHolder::group(), info(), edm::make_waiting_task(), prefetchRequested_, submitPVValidationJobs::t, unpackBuffers-CaloStage2::token, waitingTasks_, and worker_.

473  {
474  if (skipCurrentProcess) {
475  return;
476  }
477  if (worker_ == nullptr) {
478  throw cms::Exception("LogicError") << "UnscheduledProductResolver::prefetchAsync_() called with null worker_. "
479  "This should not happen, please contact framework developers.";
480  }
481  //need to try changing prefetchRequested_ before adding to waitingTasks_
482  bool expected = false;
483  bool prefetchRequested = prefetchRequested_.compare_exchange_strong(expected, true);
484  waitingTasks_.add(waitTask);
485  if (prefetchRequested) {
486  //Have to create a new task which will make sure the state for UnscheduledProductResolver
487  // is properly set after the module has run
488  auto t = make_waiting_task([this](std::exception_ptr const* iPtr) {
489  //The exception is being rethrown because resolveProductImpl sets the ProductResolver to a failed
490  // state for the case where an exception occurs during the call to the function.
491  // Caught exception is propagated via WaitingTaskList
492  CMS_SA_ALLOW try {
493  resolveProductImpl<true>([iPtr]() {
494  if (iPtr) {
495  std::rethrow_exception(*iPtr);
496  }
497  });
498  } catch (...) {
499  waitingTasks_.doneWaiting(std::current_exception());
500  return;
501  }
502  waitingTasks_.doneWaiting(nullptr);
503  });
504 
505  ParentContext parentContext(mcc);
506  EventTransitionInfo const& info = aux_->eventTransitionInfo();
507  worker_->doWorkAsync<OccurrenceTraits<EventPrincipal, BranchActionStreamBegin> >(
508  WaitingTaskHolder(*waitTask.group(), t),
509  info,
510  token,
511  info.principal().streamID(),
512  parentContext,
513  mcc->getStreamContext());
514  }
515  }
static const TGPicture * info(bool iBackgroundIsBlack)
#define CMS_SA_ALLOW
void doWorkAsync(WaitingTaskHolder, typename T::TransitionInfoType const &, ServiceToken const &, StreamID, ParentContext const &, typename T::Context const *)
Definition: Worker.h:931
UnscheduledAuxiliary const * aux_
void doneWaiting(std::exception_ptr iPtr)
Signals that the resource is now available and tasks should be spawned.
std::atomic< bool > prefetchRequested_
void add(oneapi::tbb::task_group *, WaitingTask *)
Adds task to the waiting list.
FunctorWaitingTask< F > * make_waiting_task(F f)
Definition: WaitingTask.h:101
EventTransitionInfo const & eventTransitionInfo() const

◆ resetProductData_()

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

Reimplemented from edm::DataManagingProductResolver.

Definition at line 517 of file ProductResolvers.cc.

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

517  {
518  if (not deleteEarly) {
519  prefetchRequested_ = false;
521  }
523  }
void resetProductData_(bool deleteEarly) override
void reset()
Resets access to the resource so that added tasks will wait.
std::atomic< bool > prefetchRequested_

◆ resolveProduct_()

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

Implements edm::ProductResolverBase.

Definition at line 458 of file ProductResolvers.cc.

References Resolution, and worker_.

461  {
462  if (!skipCurrentProcess and worker_) {
463  return resolveProductImpl<false>([] {});
464  }
465  return Resolution(nullptr);
466  }

◆ setupUnscheduled()

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

Reimplemented from edm::ProductResolverBase.

Definition at line 453 of file ProductResolvers.cc.

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

453  {
454  aux_ = iConfigure.auxiliary();
455  worker_ = iConfigure.findWorker(branchDescription().moduleLabel());
456  }
UnscheduledAuxiliary const * aux_
std::string const & moduleLabel() const
BranchDescription const & branchDescription() const

◆ unscheduledWasNotRun_()

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

Member Data Documentation

◆ aux_

UnscheduledAuxiliary const* edm::UnscheduledProductResolver::aux_ = nullptr
private

Definition at line 252 of file ProductResolvers.h.

Referenced by prefetchAsync_(), and setupUnscheduled().

◆ prefetchRequested_

std::atomic<bool> edm::UnscheduledProductResolver::prefetchRequested_ = false
mutableprivate

Definition at line 254 of file ProductResolvers.h.

Referenced by prefetchAsync_(), and resetProductData_().

◆ waitingTasks_

WaitingTaskList edm::UnscheduledProductResolver::waitingTasks_
mutableprivate

Definition at line 251 of file ProductResolvers.h.

Referenced by prefetchAsync_(), and resetProductData_().

◆ worker_

Worker* edm::UnscheduledProductResolver::worker_ = nullptr
private

Definition at line 253 of file ProductResolvers.h.

Referenced by prefetchAsync_(), resolveProduct_(), and setupUnscheduled().