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.

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

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

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

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

494  {
495  if (not deleteEarly) {
496  prefetchRequested_ = false;
498  }
500  }
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 435 of file ProductResolvers.cc.

References Resolution, and worker_.

438  {
439  if (!skipCurrentProcess and worker_) {
440  return resolveProductImpl<false>([] {});
441  }
442  return Resolution(nullptr);
443  }

◆ setupUnscheduled()

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

Reimplemented from edm::ProductResolverBase.

Definition at line 430 of file ProductResolvers.cc.

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

430  {
431  aux_ = iConfigure.auxiliary();
432  worker_ = iConfigure.findWorker(branchDescription().moduleLabel());
433  }
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().