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 442 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_.

447  {
448  if (skipCurrentProcess) {
449  return;
450  }
451  if (worker_ == nullptr) {
452  throw cms::Exception("LogicError") << "UnscheduledProductResolver::prefetchAsync_() called with null worker_. "
453  "This should not happen, please contact framework developers.";
454  }
455  //need to try changing prefetchRequested_ before adding to waitingTasks_
456  bool expected = false;
457  bool prefetchRequested = prefetchRequested_.compare_exchange_strong(expected, true);
458  waitingTasks_.add(waitTask);
459  if (prefetchRequested) {
460  //Have to create a new task which will make sure the state for UnscheduledProductResolver
461  // is properly set after the module has run
462  auto t = make_waiting_task([this](std::exception_ptr const* iPtr) {
463  //The exception is being rethrown because resolveProductImpl sets the ProductResolver to a failed
464  // state for the case where an exception occurs during the call to the function.
465  // Caught exception is propagated via WaitingTaskList
466  CMS_SA_ALLOW try {
467  resolveProductImpl<true>([iPtr]() {
468  if (iPtr) {
469  std::rethrow_exception(*iPtr);
470  }
471  });
472  } catch (...) {
473  waitingTasks_.doneWaiting(std::current_exception());
474  return;
475  }
476  waitingTasks_.doneWaiting(nullptr);
477  });
478 
479  ParentContext parentContext(mcc);
480  EventTransitionInfo const& info = aux_->eventTransitionInfo();
481  worker_->doWorkAsync<OccurrenceTraits<EventPrincipal, BranchActionStreamBegin> >(
482  WaitingTaskHolder(*waitTask.group(), t),
483  info,
484  token,
485  info.principal().streamID(),
486  parentContext,
487  mcc->getStreamContext());
488  }
489  }
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:968
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:92
EventTransitionInfo const & eventTransitionInfo() const

◆ resetProductData_()

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

Reimplemented from edm::DataManagingProductResolver.

Definition at line 491 of file ProductResolvers.cc.

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

491  {
492  if (not deleteEarly) {
493  prefetchRequested_ = false;
495  }
497  }
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 432 of file ProductResolvers.cc.

References Resolution, and worker_.

435  {
436  if (!skipCurrentProcess and worker_) {
437  return resolveProductImpl<false>([] {});
438  }
439  return Resolution(nullptr);
440  }

◆ setupUnscheduled()

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

Reimplemented from edm::ProductResolverBase.

Definition at line 427 of file ProductResolvers.cc.

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

427  {
428  aux_ = iConfigure.auxiliary();
429  worker_ = iConfigure.findWorker(branchDescription().moduleLabel());
430  }
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().