Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-09-23 22:37:19

0001 #ifndef FWCore_Framework_ProductResolvers_h
0002 #define FWCore_Framework_ProductResolvers_h
0003 
0004 /*----------------------------------------------------------------------
0005 
0006 ProductResolver: A collection of information related to a single WrapperBase or
0007 a set of related EDProducts. This is the storage unit of such information.
0008 
0009 ----------------------------------------------------------------------*/
0010 #include "FWCore/Framework/interface/ProductResolverBase.h"
0011 #include "FWCore/Framework/interface/ProductPutterBase.h"
0012 #include "FWCore/Framework/src/ProductPutOrMergerBase.h"
0013 #include "DataFormats/Common/interface/WrapperBase.h"
0014 #include "DataFormats/Common/interface/ProductData.h"
0015 #include "DataFormats/Provenance/interface/BranchDescription.h"
0016 #include "DataFormats/Provenance/interface/BranchID.h"
0017 #include "DataFormats/Provenance/interface/Provenance.h"
0018 #include "FWCore/Framework/interface/Principal.h"
0019 #include "FWCore/ServiceRegistry/interface/GlobalContext.h"
0020 #include "FWCore/ServiceRegistry/interface/ModuleCallingContext.h"
0021 #include "FWCore/Utilities/interface/BranchType.h"
0022 #include "FWCore/Utilities/interface/ProductResolverIndex.h"
0023 #include "FWCore/Utilities/interface/TypeID.h"
0024 #include "FWCore/Utilities/interface/thread_safety_macros.h"
0025 #include "FWCore/Concurrency/interface/WaitingTaskList.h"
0026 #include "FWCore/Concurrency/interface/WaitingTaskHolder.h"
0027 
0028 #include <atomic>
0029 #include <memory>
0030 #include <string>
0031 
0032 namespace edm {
0033   class MergeableRunProductMetadata;
0034   class ProductProvenanceRetriever;
0035   class DelayedReader;
0036   class SharedResourcesAcquirer;
0037   class UnscheduledAuxiliary;
0038   class Worker;
0039   class ServiceToken;
0040 
0041   class DataManagingOrAliasProductResolver : public ProductResolverBase {
0042   public:
0043     DataManagingOrAliasProductResolver() : ProductResolverBase{} {}
0044 
0045     // Give AliasProductResolver and SwitchBaseProductResolver access by moving this method to public
0046     void resetProductData_(bool deleteEarly) override = 0;
0047     virtual ProductData const& getProductData() const = 0;
0048   };
0049 
0050   class DataManagingProductResolver : public DataManagingOrAliasProductResolver {
0051   public:
0052     enum class ProductStatus { ProductSet, NotPut, ResolveFailed, ResolveNotRun, ProductDeleted };
0053 
0054     DataManagingProductResolver(std::shared_ptr<BranchDescription const> bd, ProductStatus iDefaultStatus)
0055         : DataManagingOrAliasProductResolver(),
0056           productData_(bd),
0057           theStatus_(iDefaultStatus),
0058           defaultStatus_(iDefaultStatus) {}
0059 
0060     void connectTo(ProductResolverBase const&, Principal const*) final;
0061 
0062     void resetStatus() { theStatus_ = defaultStatus_; }
0063 
0064     void resetProductData_(bool deleteEarly) override;
0065 
0066   protected:
0067     void setProduct(std::unique_ptr<WrapperBase> edp) const;
0068     void setProduct(std::shared_ptr<WrapperBase> edp) const;
0069     ProductStatus status() const { return theStatus_; }
0070     ProductStatus defaultStatus() const { return defaultStatus_; }
0071     void setFailedStatus() const { theStatus_ = ProductStatus::ResolveFailed; }
0072     //Handle the boilerplate code needed for resolveProduct_
0073     template <bool callResolver, typename FUNC>
0074     Resolution resolveProductImpl(FUNC resolver) const;
0075     ProductData const& getProductData() const final { return productData_; }
0076     void setMergeableRunProductMetadataInProductData(MergeableRunProductMetadata const*);
0077 
0078     void checkType(WrapperBase const& prod) const;
0079 
0080   private:
0081     void throwProductDeletedException() const;
0082     virtual bool isFromCurrentProcess() const = 0;
0083 
0084     bool productUnavailable_() const final;
0085     bool productResolved_() const final;
0086     bool productWasDeleted_() const final;
0087     bool productWasFetchedAndIsValid_(bool iSkipCurrentProcess) const final;
0088 
0089     BranchDescription const& branchDescription_() const final { return *getProductData().branchDescription(); }
0090     void resetBranchDescription_(std::shared_ptr<BranchDescription const> bd) final {
0091       productData_.resetBranchDescription(bd);
0092     }
0093     Provenance const* provenance_() const final { return &productData_.provenance(); }
0094 
0095     std::string const& resolvedModuleLabel_() const final { return moduleLabel(); }
0096     void setProductProvenanceRetriever_(ProductProvenanceRetriever const* provRetriever) final;
0097     void setProductID_(ProductID const& pid) final;
0098     ProductProvenance const* productProvenancePtr_() const final;
0099     bool singleProduct_() const final;
0100 
0101     ProductData productData_;
0102     mutable std::atomic<ProductStatus> theStatus_;
0103     ProductStatus const defaultStatus_;
0104   };
0105 
0106   class MergeableInputProductResolver : public DataManagingProductResolver {
0107   public:
0108     MergeableInputProductResolver(std::shared_ptr<BranchDescription const> bd, ProductStatus iDefaultStatus)
0109         : DataManagingProductResolver(bd, iDefaultStatus) {}
0110 
0111   protected:
0112     void setOrMergeProduct(std::shared_ptr<WrapperBase> prod,
0113                            MergeableRunProductMetadata const* mergeableRunProductMetadata) const;
0114 
0115     // merges the product with the pre-existing product
0116     void mergeProduct(std::shared_ptr<WrapperBase> edp, MergeableRunProductMetadata const*) const;
0117   };
0118 
0119   class DelayedReaderInputProductResolver : public MergeableInputProductResolver {
0120   public:
0121     explicit DelayedReaderInputProductResolver(std::shared_ptr<BranchDescription const> bd)
0122         : MergeableInputProductResolver(bd, ProductStatus::ResolveNotRun), m_prefetchRequested{false}, aux_{nullptr} {
0123       assert(bd->onDemand());
0124       assert(not bd->produced());
0125     }
0126 
0127     void setupUnscheduled(UnscheduledConfigurator const&) final;
0128 
0129   private:
0130     bool isFromCurrentProcess() const final;
0131 
0132     Resolution resolveProduct_(Principal const& principal,
0133                                bool skipCurrentProcess,
0134                                SharedResourcesAcquirer* sra,
0135                                ModuleCallingContext const* mcc) const override;
0136     void prefetchAsync_(WaitingTaskHolder waitTask,
0137                         Principal const& principal,
0138                         bool skipCurrentProcess,
0139                         ServiceToken const& token,
0140                         SharedResourcesAcquirer* sra,
0141                         ModuleCallingContext const* mcc) const override;
0142 
0143     void retrieveAndMerge_(Principal const& principal,
0144                            MergeableRunProductMetadata const* mergeableRunProductMetadata) const override;
0145 
0146     void setMergeableRunProductMetadata_(MergeableRunProductMetadata const*) override;
0147 
0148     bool unscheduledWasNotRun_() const final { return false; }
0149 
0150     void resetProductData_(bool deleteEarly) override;
0151 
0152     mutable std::atomic<bool> m_prefetchRequested;
0153     CMS_THREAD_SAFE mutable WaitingTaskList m_waitingTasks;
0154     UnscheduledAuxiliary const* aux_;  //provides access to the delayedGet signals
0155   };
0156 
0157   class PutOnReadInputProductResolver : public MergeableInputProductResolver,
0158                                         public ProductPutterBase,
0159                                         public ProductPutOrMergerBase {
0160   public:
0161     PutOnReadInputProductResolver(std::shared_ptr<BranchDescription const> bd)
0162         : MergeableInputProductResolver(bd, ProductStatus::ResolveNotRun) {
0163       assert(not bd->produced());
0164       assert(not bd->onDemand());
0165     }
0166 
0167   protected:
0168     void putProduct(std::unique_ptr<WrapperBase> edp) const override;
0169     void putOrMergeProduct(std::unique_ptr<WrapperBase> prod) const override;
0170 
0171     Resolution resolveProduct_(Principal const& principal,
0172                                bool skipCurrentProcess,
0173                                SharedResourcesAcquirer* sra,
0174                                ModuleCallingContext const* mcc) const final;
0175     void prefetchAsync_(WaitingTaskHolder waitTask,
0176                         Principal const& principal,
0177                         bool skipCurrentProcess,
0178                         ServiceToken const& token,
0179                         SharedResourcesAcquirer* sra,
0180                         ModuleCallingContext const* mcc) const final;
0181     bool unscheduledWasNotRun_() const final { return false; }
0182 
0183   private:
0184     bool isFromCurrentProcess() const final;
0185   };
0186 
0187   class ProducedProductResolver : public DataManagingProductResolver, public ProductPutterBase {
0188   public:
0189     ProducedProductResolver(std::shared_ptr<BranchDescription const> bd, ProductStatus iDefaultStatus)
0190         : DataManagingProductResolver(bd, iDefaultStatus) {
0191       assert(bd->produced());
0192     }
0193 
0194   protected:
0195     void putProduct(std::unique_ptr<WrapperBase> edp) const override;
0196 
0197   private:
0198     bool isFromCurrentProcess() const final;
0199   };
0200 
0201   class PuttableProductResolver : public ProducedProductResolver {
0202   public:
0203     explicit PuttableProductResolver(std::shared_ptr<BranchDescription const> bd)
0204         : ProducedProductResolver(bd, ProductStatus::NotPut) {}
0205 
0206     void setupUnscheduled(UnscheduledConfigurator const&) final;
0207 
0208   private:
0209     Resolution resolveProduct_(Principal const& principal,
0210                                bool skipCurrentProcess,
0211                                SharedResourcesAcquirer* sra,
0212                                ModuleCallingContext const* mcc) const override;
0213     void prefetchAsync_(WaitingTaskHolder waitTask,
0214                         Principal const& principal,
0215                         bool skipCurrentProcess,
0216                         ServiceToken const& token,
0217                         SharedResourcesAcquirer* sra,
0218                         ModuleCallingContext const* mcc) const override;
0219     bool unscheduledWasNotRun_() const override { return false; }
0220 
0221     // The WaitingTaskList below is the one from the worker, if one
0222     // corresponds to this ProductResolver. For the Source-like cases
0223     // where there is no such Worker, the tasks depending on the data
0224     // depending on this ProductResolver are assumed to be eligible to
0225     // run immediately after their prefetch.
0226     WaitingTaskList* waitingTasks_ = nullptr;
0227   };
0228 
0229   class UnscheduledProductResolver : public ProducedProductResolver {
0230   public:
0231     explicit UnscheduledProductResolver(std::shared_ptr<BranchDescription const> bd)
0232         : ProducedProductResolver(bd, ProductStatus::ResolveNotRun) {}
0233 
0234     void setupUnscheduled(UnscheduledConfigurator const&) final;
0235 
0236   private:
0237     Resolution resolveProduct_(Principal const& principal,
0238                                bool skipCurrentProcess,
0239                                SharedResourcesAcquirer* sra,
0240                                ModuleCallingContext const* mcc) const override;
0241     void prefetchAsync_(WaitingTaskHolder waitTask,
0242                         Principal const& principal,
0243                         bool skipCurrentProcess,
0244                         ServiceToken const& token,
0245                         SharedResourcesAcquirer* sra,
0246                         ModuleCallingContext const* mcc) const override;
0247     bool unscheduledWasNotRun_() const override { return status() == ProductStatus::ResolveNotRun; }
0248 
0249     void resetProductData_(bool deleteEarly) override;
0250 
0251     CMS_THREAD_SAFE mutable WaitingTaskList waitingTasks_;
0252     UnscheduledAuxiliary const* aux_ = nullptr;
0253     Worker* worker_ = nullptr;
0254     mutable std::atomic<bool> prefetchRequested_ = false;
0255   };
0256 
0257   class TransformingProductResolver : public ProducedProductResolver {
0258   public:
0259     explicit TransformingProductResolver(std::shared_ptr<BranchDescription const> bd)
0260         : ProducedProductResolver(bd, ProductStatus::ResolveFailed), mcc_(nullptr) {}
0261 
0262     void setupUnscheduled(UnscheduledConfigurator const&) final;
0263 
0264   private:
0265     Resolution resolveProduct_(Principal const& principal,
0266                                bool skipCurrentProcess,
0267                                SharedResourcesAcquirer* sra,
0268                                ModuleCallingContext const* mcc) const override;
0269     void prefetchAsync_(WaitingTaskHolder waitTask,
0270                         Principal const& principal,
0271                         bool skipCurrentProcess,
0272                         ServiceToken const& token,
0273                         SharedResourcesAcquirer* sra,
0274                         ModuleCallingContext const* mcc) const override;
0275     bool unscheduledWasNotRun_() const override { return status() == ProductStatus::ResolveNotRun; }
0276 
0277     void resetProductData_(bool deleteEarly) override;
0278 
0279     CMS_THREAD_SAFE mutable WaitingTaskList waitingTasks_;
0280     UnscheduledAuxiliary const* aux_ = nullptr;
0281     Worker* worker_ = nullptr;
0282     CMS_THREAD_GUARD(prefetchRequested_) mutable ModuleCallingContext mcc_;
0283     size_t index_;
0284     mutable std::atomic<bool> prefetchRequested_ = false;
0285   };
0286 
0287   class AliasProductResolver : public DataManagingOrAliasProductResolver {
0288   public:
0289     typedef ProducedProductResolver::ProductStatus ProductStatus;
0290     explicit AliasProductResolver(std::shared_ptr<BranchDescription const> bd,
0291                                   DataManagingOrAliasProductResolver& realProduct)
0292         : DataManagingOrAliasProductResolver(), realProduct_(realProduct), bd_(bd) {}
0293 
0294     void connectTo(ProductResolverBase const& iOther, Principal const* iParentPrincipal) final {
0295       realProduct_.connectTo(iOther, iParentPrincipal);
0296     };
0297 
0298   private:
0299     Resolution resolveProduct_(Principal const& principal,
0300                                bool skipCurrentProcess,
0301                                SharedResourcesAcquirer* sra,
0302                                ModuleCallingContext const* mcc) const override {
0303       return realProduct_.resolveProduct(principal, skipCurrentProcess, sra, mcc);
0304     }
0305     void prefetchAsync_(WaitingTaskHolder waitTask,
0306                         Principal const& principal,
0307                         bool skipCurrentProcess,
0308                         ServiceToken const& token,
0309                         SharedResourcesAcquirer* sra,
0310                         ModuleCallingContext const* mcc) const override {
0311       realProduct_.prefetchAsync(waitTask, principal, skipCurrentProcess, token, sra, mcc);
0312     }
0313     bool unscheduledWasNotRun_() const override { return realProduct_.unscheduledWasNotRun(); }
0314     bool productUnavailable_() const override { return realProduct_.productUnavailable(); }
0315     bool productResolved_() const final { return realProduct_.productResolved(); }
0316     bool productWasDeleted_() const override { return realProduct_.productWasDeleted(); }
0317     bool productWasFetchedAndIsValid_(bool iSkipCurrentProcess) const final {
0318       return realProduct_.productWasFetchedAndIsValid(iSkipCurrentProcess);
0319     }
0320 
0321     BranchDescription const& branchDescription_() const override { return *bd_; }
0322     void resetBranchDescription_(std::shared_ptr<BranchDescription const> bd) override { bd_ = bd; }
0323     Provenance const* provenance_() const final { return realProduct_.provenance(); }
0324 
0325     std::string const& resolvedModuleLabel_() const override { return realProduct_.moduleLabel(); }
0326     void setProductProvenanceRetriever_(ProductProvenanceRetriever const* provRetriever) override;
0327     void setProductID_(ProductID const& pid) override;
0328     ProductProvenance const* productProvenancePtr_() const override;
0329     void resetProductData_(bool deleteEarly) override;
0330     ProductData const& getProductData() const final { return realProduct_.getProductData(); }
0331     bool singleProduct_() const override;
0332 
0333     DataManagingOrAliasProductResolver& realProduct_;
0334     std::shared_ptr<BranchDescription const> bd_;
0335   };
0336 
0337   // Switch is a mixture of DataManaging (for worker and provenance) and Alias (for product)
0338   class SwitchBaseProductResolver : public DataManagingOrAliasProductResolver {
0339   public:
0340     using ProductStatus = DataManagingProductResolver::ProductStatus;
0341     SwitchBaseProductResolver(std::shared_ptr<BranchDescription const> bd,
0342                               DataManagingOrAliasProductResolver& realProduct);
0343 
0344     void connectTo(ProductResolverBase const& iOther, Principal const* iParentPrincipal) final;
0345     void setupUnscheduled(UnscheduledConfigurator const& iConfigure) final;
0346 
0347   protected:
0348     Resolution resolveProductImpl(Resolution) const;
0349     WaitingTaskList& waitingTasks() const { return waitingTasks_; }
0350     Worker* worker() const { return worker_; }
0351     DataManagingOrAliasProductResolver const& realProduct() const { return realProduct_; }
0352     std::atomic<bool>& prefetchRequested() const { return prefetchRequested_; }
0353     void unsafe_setWrapperAndProvenance() const;
0354     void resetProductData_(bool deleteEarly) override;
0355 
0356   private:
0357     bool productResolved_() const final;
0358     bool productWasDeleted_() const final { return realProduct_.productWasDeleted(); }
0359     bool productWasFetchedAndIsValid_(bool iSkipCurrentProcess) const final {
0360       return realProduct_.productWasFetchedAndIsValid(iSkipCurrentProcess);
0361     }
0362     BranchDescription const& branchDescription_() const final {
0363       return *productData_.branchDescription();
0364       ;
0365     }
0366     void resetBranchDescription_(std::shared_ptr<BranchDescription const> bd) final {
0367       productData_.resetBranchDescription(bd);
0368     }
0369     Provenance const* provenance_() const final { return &productData_.provenance(); }
0370     std::string const& resolvedModuleLabel_() const final { return moduleLabel(); }
0371     void setProductProvenanceRetriever_(ProductProvenanceRetriever const* provRetriever) final;
0372     void setProductID_(ProductID const& pid) final;
0373     ProductProvenance const* productProvenancePtr_() const final { return provenance()->productProvenance(); }
0374     ProductData const& getProductData() const final { return productData_; }
0375     bool singleProduct_() const final { return true; }
0376 
0377     // for "alias" view
0378     DataManagingOrAliasProductResolver& realProduct_;
0379     // for "product" view
0380     ProductData productData_;
0381     Worker* worker_ = nullptr;
0382     CMS_THREAD_SAFE mutable WaitingTaskList waitingTasks_;
0383     mutable std::atomic<bool> prefetchRequested_;
0384     // for provenance
0385     ParentageID parentageID_;
0386   };
0387 
0388   // For the case when SwitchProducer is on a Path
0389   class SwitchProducerProductResolver : public SwitchBaseProductResolver, public ProductPutterBase {
0390   public:
0391     SwitchProducerProductResolver(std::shared_ptr<BranchDescription const> bd,
0392                                   DataManagingOrAliasProductResolver& realProduct);
0393 
0394   private:
0395     Resolution resolveProduct_(Principal const& principal,
0396                                bool skipCurrentProcess,
0397                                SharedResourcesAcquirer* sra,
0398                                ModuleCallingContext const* mcc) const final;
0399     void prefetchAsync_(WaitingTaskHolder waitTask,
0400                         Principal const& principal,
0401                         bool skipCurrentProcess,
0402                         ServiceToken const& token,
0403                         SharedResourcesAcquirer* sra,
0404                         ModuleCallingContext const* mcc) const final;
0405     void putProduct(std::unique_ptr<WrapperBase> edp) const final;
0406     bool unscheduledWasNotRun_() const final { return false; }
0407     bool productUnavailable_() const final;
0408     void resetProductData_(bool deleteEarly) final;
0409 
0410     constexpr static const ProductStatus defaultStatus_ = ProductStatus::NotPut;
0411 
0412     // for filter in a Path
0413     // The variable is only modified or read at times where the
0414     //  framework has guaranteed synchronization between write and read
0415     CMS_THREAD_SAFE mutable ProductStatus status_;
0416   };
0417 
0418   // For the case when SwitchProducer is not on any Path
0419   class SwitchAliasProductResolver : public SwitchBaseProductResolver {
0420   public:
0421     SwitchAliasProductResolver(std::shared_ptr<BranchDescription const> bd,
0422                                DataManagingOrAliasProductResolver& realProduct)
0423         : SwitchBaseProductResolver(std::move(bd), realProduct) {}
0424 
0425   private:
0426     Resolution resolveProduct_(Principal const& principal,
0427                                bool skipCurrentProcess,
0428                                SharedResourcesAcquirer* sra,
0429                                ModuleCallingContext const* mcc) const final;
0430     void prefetchAsync_(WaitingTaskHolder waitTask,
0431                         Principal const& principal,
0432                         bool skipCurrentProcess,
0433                         ServiceToken const& token,
0434                         SharedResourcesAcquirer* sra,
0435                         ModuleCallingContext const* mcc) const final;
0436     bool unscheduledWasNotRun_() const final { return realProduct().unscheduledWasNotRun(); }
0437     bool productUnavailable_() const final { return realProduct().productUnavailable(); }
0438   };
0439 
0440   class ParentProcessProductResolver : public ProductResolverBase {
0441   public:
0442     typedef ProducedProductResolver::ProductStatus ProductStatus;
0443     explicit ParentProcessProductResolver(std::shared_ptr<BranchDescription const> bd)
0444         : ProductResolverBase(), realProduct_(nullptr), bd_(bd), provRetriever_(nullptr), parentPrincipal_(nullptr) {}
0445 
0446     void connectTo(ProductResolverBase const& iOther, Principal const* iParentPrincipal) final {
0447       realProduct_ = &iOther;
0448       parentPrincipal_ = iParentPrincipal;
0449     };
0450 
0451   private:
0452     Resolution resolveProduct_(Principal const& principal,
0453                                bool skipCurrentProcess,
0454                                SharedResourcesAcquirer* sra,
0455                                ModuleCallingContext const* mcc) const override {
0456       if (principal.branchType() == InProcess &&
0457           (mcc->parent().globalContext()->transition() == GlobalContext::Transition::kBeginProcessBlock ||
0458            mcc->parent().globalContext()->transition() == GlobalContext::Transition::kEndProcessBlock)) {
0459         return Resolution(nullptr);
0460       }
0461 
0462       skipCurrentProcess = false;
0463       return realProduct_->resolveProduct(*parentPrincipal_, skipCurrentProcess, sra, mcc);
0464     }
0465     void prefetchAsync_(WaitingTaskHolder waitTask,
0466                         Principal const& principal,
0467                         bool skipCurrentProcess,
0468                         ServiceToken const& token,
0469                         SharedResourcesAcquirer* sra,
0470                         ModuleCallingContext const* mcc) const override {
0471       if (principal.branchType() == InProcess &&
0472           (mcc->parent().globalContext()->transition() == GlobalContext::Transition::kBeginProcessBlock ||
0473            mcc->parent().globalContext()->transition() == GlobalContext::Transition::kEndProcessBlock)) {
0474         return;
0475       }
0476 
0477       skipCurrentProcess = false;
0478       realProduct_->prefetchAsync(waitTask, *parentPrincipal_, skipCurrentProcess, token, sra, mcc);
0479     }
0480     bool unscheduledWasNotRun_() const override {
0481       if (realProduct_)
0482         return realProduct_->unscheduledWasNotRun();
0483       throwNullRealProduct();
0484       return false;
0485     }
0486     bool productUnavailable_() const override { return realProduct_->productUnavailable(); }
0487     bool productResolved_() const final { return realProduct_->productResolved(); }
0488     bool productWasDeleted_() const override { return realProduct_->productWasDeleted(); }
0489     bool productWasFetchedAndIsValid_(bool iSkipCurrentProcess) const override {
0490       iSkipCurrentProcess = false;
0491       return realProduct_->productWasFetchedAndIsValid(iSkipCurrentProcess);
0492     }
0493 
0494     BranchDescription const& branchDescription_() const override { return *bd_; }
0495     void resetBranchDescription_(std::shared_ptr<BranchDescription const> bd) override { bd_ = bd; }
0496     Provenance const* provenance_() const final { return realProduct_->provenance(); }
0497     std::string const& resolvedModuleLabel_() const override { return realProduct_->moduleLabel(); }
0498     void setProductProvenanceRetriever_(ProductProvenanceRetriever const* provRetriever) override;
0499     void setProductID_(ProductID const& pid) override;
0500     ProductProvenance const* productProvenancePtr_() const override;
0501     void resetProductData_(bool deleteEarly) override;
0502     bool singleProduct_() const override;
0503     void throwNullRealProduct() const;
0504 
0505     ProductResolverBase const* realProduct_;
0506     std::shared_ptr<BranchDescription const> bd_;
0507     ProductProvenanceRetriever const* provRetriever_;
0508     Principal const* parentPrincipal_;
0509   };
0510 
0511   class NoProcessProductResolver : public ProductResolverBase {
0512   public:
0513     typedef ProducedProductResolver::ProductStatus ProductStatus;
0514     NoProcessProductResolver(std::vector<ProductResolverIndex> const& matchingHolders,
0515                              std::vector<bool> const& ambiguous,
0516                              bool madeAtEnd);
0517 
0518     void connectTo(ProductResolverBase const& iOther, Principal const*) final;
0519 
0520     void tryPrefetchResolverAsync(unsigned int iProcessingIndex,
0521                                   Principal const& principal,
0522                                   bool skipCurrentProcess,
0523                                   SharedResourcesAcquirer* sra,
0524                                   ModuleCallingContext const* mcc,
0525                                   ServiceToken token,
0526                                   oneapi::tbb::task_group*) const;
0527 
0528     bool dataValidFromResolver(unsigned int iProcessingIndex,
0529                                Principal const& principal,
0530                                bool iSkipCurrentProcess) const;
0531 
0532     void prefetchFailed(unsigned int iProcessingIndex,
0533                         Principal const& principal,
0534                         bool iSkipCurrentProcess,
0535                         std::exception_ptr iExceptPtr) const;
0536 
0537   private:
0538     unsigned int unsetIndexValue() const;
0539     Resolution resolveProduct_(Principal const& principal,
0540                                bool skipCurrentProcess,
0541                                SharedResourcesAcquirer* sra,
0542                                ModuleCallingContext const* mcc) const override;
0543     void prefetchAsync_(WaitingTaskHolder waitTask,
0544                         Principal const& principal,
0545                         bool skipCurrentProcess,
0546                         ServiceToken const& token,
0547                         SharedResourcesAcquirer* sra,
0548                         ModuleCallingContext const* mcc) const override;
0549     bool unscheduledWasNotRun_() const override;
0550     bool productUnavailable_() const override;
0551     bool productWasDeleted_() const override;
0552     bool productResolved_() const final;
0553     bool productWasFetchedAndIsValid_(bool iSkipCurrentProcess) const override;
0554 
0555     BranchDescription const& branchDescription_() const override;
0556     void resetBranchDescription_(std::shared_ptr<BranchDescription const> bd) override;
0557     Provenance const* provenance_() const override;
0558 
0559     std::string const& resolvedModuleLabel_() const override { return moduleLabel(); }
0560     void setProductProvenanceRetriever_(ProductProvenanceRetriever const* provRetriever) override;
0561     void setProductID_(ProductID const& pid) override;
0562     ProductProvenance const* productProvenancePtr_() const override;
0563     void resetProductData_(bool deleteEarly) override;
0564     bool singleProduct_() const override;
0565 
0566     Resolution tryResolver(unsigned int index,
0567                            Principal const& principal,
0568                            bool skipCurrentProcess,
0569                            SharedResourcesAcquirer* sra,
0570                            ModuleCallingContext const* mcc) const;
0571 
0572     void setCache(bool skipCurrentProcess, ProductResolverIndex index, std::exception_ptr exceptionPtr) const;
0573 
0574     std::vector<ProductResolverIndex> matchingHolders_;
0575     std::vector<bool> ambiguous_;
0576     CMS_THREAD_SAFE mutable WaitingTaskList waitingTasks_;
0577     CMS_THREAD_SAFE mutable WaitingTaskList skippingWaitingTasks_;
0578     mutable std::atomic<unsigned int> lastCheckIndex_;
0579     mutable std::atomic<unsigned int> lastSkipCurrentCheckIndex_;
0580     mutable std::atomic<bool> prefetchRequested_;
0581     mutable std::atomic<bool> skippingPrefetchRequested_;
0582     const bool madeAtEnd_;
0583   };
0584 
0585   class SingleChoiceNoProcessProductResolver : public ProductResolverBase {
0586   public:
0587     typedef ProducedProductResolver::ProductStatus ProductStatus;
0588     SingleChoiceNoProcessProductResolver(ProductResolverIndex iChoice)
0589         : ProductResolverBase(), realResolverIndex_(iChoice) {}
0590 
0591     void connectTo(ProductResolverBase const& iOther, Principal const*) final;
0592 
0593   private:
0594     Resolution resolveProduct_(Principal const& principal,
0595                                bool skipCurrentProcess,
0596                                SharedResourcesAcquirer* sra,
0597                                ModuleCallingContext const* mcc) const override;
0598     void prefetchAsync_(WaitingTaskHolder waitTask,
0599                         Principal const& principal,
0600                         bool skipCurrentProcess,
0601                         ServiceToken const& token,
0602                         SharedResourcesAcquirer* sra,
0603                         ModuleCallingContext const* mcc) const override;
0604     bool unscheduledWasNotRun_() const override;
0605     bool productUnavailable_() const override;
0606     bool productWasDeleted_() const override;
0607     bool productResolved_() const final;
0608     bool productWasFetchedAndIsValid_(bool iSkipCurrentProcess) const override;
0609 
0610     BranchDescription const& branchDescription_() const override;
0611     void resetBranchDescription_(std::shared_ptr<BranchDescription const> bd) override;
0612     Provenance const* provenance_() const override;
0613 
0614     std::string const& resolvedModuleLabel_() const override { return moduleLabel(); }
0615     void setProductProvenanceRetriever_(ProductProvenanceRetriever const* provRetriever) override;
0616     void setProductID_(ProductID const& pid) override;
0617     ProductProvenance const* productProvenancePtr_() const override;
0618     void resetProductData_(bool deleteEarly) override;
0619     bool singleProduct_() const override;
0620 
0621     ProductResolverIndex realResolverIndex_;
0622   };
0623 
0624 }  // namespace edm
0625 
0626 #endif