Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-24 02:18:45

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), worker_(nullptr), prefetchRequested_(false) {}
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     void putProduct(std::unique_ptr<WrapperBase> edp) const override;
0222     void resetProductData_(bool deleteEarly) override;
0223 
0224     CMS_THREAD_SAFE mutable WaitingTaskList m_waitingTasks;
0225     Worker* worker_;
0226     mutable std::atomic<bool> prefetchRequested_;
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 AliasProductResolver : public DataManagingOrAliasProductResolver {
0258   public:
0259     typedef ProducedProductResolver::ProductStatus ProductStatus;
0260     explicit AliasProductResolver(std::shared_ptr<BranchDescription const> bd,
0261                                   DataManagingOrAliasProductResolver& realProduct)
0262         : DataManagingOrAliasProductResolver(), realProduct_(realProduct), bd_(bd) {}
0263 
0264     void connectTo(ProductResolverBase const& iOther, Principal const* iParentPrincipal) final {
0265       realProduct_.connectTo(iOther, iParentPrincipal);
0266     };
0267 
0268   private:
0269     Resolution resolveProduct_(Principal const& principal,
0270                                bool skipCurrentProcess,
0271                                SharedResourcesAcquirer* sra,
0272                                ModuleCallingContext const* mcc) const override {
0273       return realProduct_.resolveProduct(principal, skipCurrentProcess, sra, mcc);
0274     }
0275     void prefetchAsync_(WaitingTaskHolder waitTask,
0276                         Principal const& principal,
0277                         bool skipCurrentProcess,
0278                         ServiceToken const& token,
0279                         SharedResourcesAcquirer* sra,
0280                         ModuleCallingContext const* mcc) const override {
0281       realProduct_.prefetchAsync(waitTask, principal, skipCurrentProcess, token, sra, mcc);
0282     }
0283     bool unscheduledWasNotRun_() const override { return realProduct_.unscheduledWasNotRun(); }
0284     bool productUnavailable_() const override { return realProduct_.productUnavailable(); }
0285     bool productResolved_() const final { return realProduct_.productResolved(); }
0286     bool productWasDeleted_() const override { return realProduct_.productWasDeleted(); }
0287     bool productWasFetchedAndIsValid_(bool iSkipCurrentProcess) const final {
0288       return realProduct_.productWasFetchedAndIsValid(iSkipCurrentProcess);
0289     }
0290 
0291     BranchDescription const& branchDescription_() const override { return *bd_; }
0292     void resetBranchDescription_(std::shared_ptr<BranchDescription const> bd) override { bd_ = bd; }
0293     Provenance const* provenance_() const final { return realProduct_.provenance(); }
0294 
0295     std::string const& resolvedModuleLabel_() const override { return realProduct_.moduleLabel(); }
0296     void setProductProvenanceRetriever_(ProductProvenanceRetriever const* provRetriever) override;
0297     void setProductID_(ProductID const& pid) override;
0298     ProductProvenance const* productProvenancePtr_() const override;
0299     void resetProductData_(bool deleteEarly) override;
0300     ProductData const& getProductData() const final { return realProduct_.getProductData(); }
0301     bool singleProduct_() const override;
0302 
0303     DataManagingOrAliasProductResolver& realProduct_;
0304     std::shared_ptr<BranchDescription const> bd_;
0305   };
0306 
0307   // Switch is a mixture of DataManaging (for worker and provenance) and Alias (for product)
0308   class SwitchBaseProductResolver : public DataManagingOrAliasProductResolver {
0309   public:
0310     using ProductStatus = DataManagingProductResolver::ProductStatus;
0311     SwitchBaseProductResolver(std::shared_ptr<BranchDescription const> bd,
0312                               DataManagingOrAliasProductResolver& realProduct);
0313 
0314     void connectTo(ProductResolverBase const& iOther, Principal const* iParentPrincipal) final;
0315     void setupUnscheduled(UnscheduledConfigurator const& iConfigure) final;
0316 
0317   protected:
0318     Resolution resolveProductImpl(Resolution) const;
0319     WaitingTaskList& waitingTasks() const { return waitingTasks_; }
0320     Worker* worker() const { return worker_; }
0321     DataManagingOrAliasProductResolver const& realProduct() const { return realProduct_; }
0322     std::atomic<bool>& prefetchRequested() const { return prefetchRequested_; }
0323     void unsafe_setWrapperAndProvenance() const;
0324     void resetProductData_(bool deleteEarly) override;
0325 
0326   private:
0327     bool productResolved_() const final;
0328     bool productWasDeleted_() const final { return realProduct_.productWasDeleted(); }
0329     bool productWasFetchedAndIsValid_(bool iSkipCurrentProcess) const final {
0330       return realProduct_.productWasFetchedAndIsValid(iSkipCurrentProcess);
0331     }
0332     BranchDescription const& branchDescription_() const final {
0333       return *productData_.branchDescription();
0334       ;
0335     }
0336     void resetBranchDescription_(std::shared_ptr<BranchDescription const> bd) final {
0337       productData_.resetBranchDescription(bd);
0338     }
0339     Provenance const* provenance_() const final { return &productData_.provenance(); }
0340     std::string const& resolvedModuleLabel_() const final { return moduleLabel(); }
0341     void setProductProvenanceRetriever_(ProductProvenanceRetriever const* provRetriever) final;
0342     void setProductID_(ProductID const& pid) final;
0343     ProductProvenance const* productProvenancePtr_() const final { return provenance()->productProvenance(); }
0344     ProductData const& getProductData() const final { return productData_; }
0345     bool singleProduct_() const final { return true; }
0346 
0347     // for "alias" view
0348     DataManagingOrAliasProductResolver& realProduct_;
0349     // for "product" view
0350     ProductData productData_;
0351     Worker* worker_ = nullptr;
0352     CMS_THREAD_SAFE mutable WaitingTaskList waitingTasks_;
0353     mutable std::atomic<bool> prefetchRequested_;
0354     // for provenance
0355     ParentageID parentageID_;
0356   };
0357 
0358   // For the case when SwitchProducer is on a Path
0359   class SwitchProducerProductResolver : public SwitchBaseProductResolver, public ProductPutterBase {
0360   public:
0361     SwitchProducerProductResolver(std::shared_ptr<BranchDescription const> bd,
0362                                   DataManagingOrAliasProductResolver& realProduct);
0363 
0364   private:
0365     Resolution resolveProduct_(Principal const& principal,
0366                                bool skipCurrentProcess,
0367                                SharedResourcesAcquirer* sra,
0368                                ModuleCallingContext const* mcc) const final;
0369     void prefetchAsync_(WaitingTaskHolder waitTask,
0370                         Principal const& principal,
0371                         bool skipCurrentProcess,
0372                         ServiceToken const& token,
0373                         SharedResourcesAcquirer* sra,
0374                         ModuleCallingContext const* mcc) const final;
0375     void putProduct(std::unique_ptr<WrapperBase> edp) const final;
0376     bool unscheduledWasNotRun_() const final { return false; }
0377     bool productUnavailable_() const final;
0378     void resetProductData_(bool deleteEarly) final;
0379 
0380     constexpr static const ProductStatus defaultStatus_ = ProductStatus::NotPut;
0381 
0382     // for filter in a Path
0383     // The variable is only modified or read at times where the
0384     //  framework has guaranteed synchronization between write and read
0385     CMS_THREAD_SAFE mutable ProductStatus status_;
0386   };
0387 
0388   // For the case when SwitchProducer is not on any Path
0389   class SwitchAliasProductResolver : public SwitchBaseProductResolver {
0390   public:
0391     SwitchAliasProductResolver(std::shared_ptr<BranchDescription const> bd,
0392                                DataManagingOrAliasProductResolver& realProduct)
0393         : SwitchBaseProductResolver(std::move(bd), realProduct) {}
0394 
0395   private:
0396     Resolution resolveProduct_(Principal const& principal,
0397                                bool skipCurrentProcess,
0398                                SharedResourcesAcquirer* sra,
0399                                ModuleCallingContext const* mcc) const final;
0400     void prefetchAsync_(WaitingTaskHolder waitTask,
0401                         Principal const& principal,
0402                         bool skipCurrentProcess,
0403                         ServiceToken const& token,
0404                         SharedResourcesAcquirer* sra,
0405                         ModuleCallingContext const* mcc) const final;
0406     bool unscheduledWasNotRun_() const final { return realProduct().unscheduledWasNotRun(); }
0407     bool productUnavailable_() const final { return realProduct().productUnavailable(); }
0408   };
0409 
0410   class ParentProcessProductResolver : public ProductResolverBase {
0411   public:
0412     typedef ProducedProductResolver::ProductStatus ProductStatus;
0413     explicit ParentProcessProductResolver(std::shared_ptr<BranchDescription const> bd)
0414         : ProductResolverBase(), realProduct_(nullptr), bd_(bd), provRetriever_(nullptr), parentPrincipal_(nullptr) {}
0415 
0416     void connectTo(ProductResolverBase const& iOther, Principal const* iParentPrincipal) final {
0417       realProduct_ = &iOther;
0418       parentPrincipal_ = iParentPrincipal;
0419     };
0420 
0421   private:
0422     Resolution resolveProduct_(Principal const& principal,
0423                                bool skipCurrentProcess,
0424                                SharedResourcesAcquirer* sra,
0425                                ModuleCallingContext const* mcc) const override {
0426       if (principal.branchType() == InProcess &&
0427           (mcc->parent().globalContext()->transition() == GlobalContext::Transition::kBeginProcessBlock ||
0428            mcc->parent().globalContext()->transition() == GlobalContext::Transition::kEndProcessBlock)) {
0429         return Resolution(nullptr);
0430       }
0431 
0432       skipCurrentProcess = false;
0433       return realProduct_->resolveProduct(*parentPrincipal_, skipCurrentProcess, sra, mcc);
0434     }
0435     void prefetchAsync_(WaitingTaskHolder waitTask,
0436                         Principal const& principal,
0437                         bool skipCurrentProcess,
0438                         ServiceToken const& token,
0439                         SharedResourcesAcquirer* sra,
0440                         ModuleCallingContext const* mcc) const override {
0441       if (principal.branchType() == InProcess &&
0442           (mcc->parent().globalContext()->transition() == GlobalContext::Transition::kBeginProcessBlock ||
0443            mcc->parent().globalContext()->transition() == GlobalContext::Transition::kEndProcessBlock)) {
0444         return;
0445       }
0446 
0447       skipCurrentProcess = false;
0448       realProduct_->prefetchAsync(waitTask, *parentPrincipal_, skipCurrentProcess, token, sra, mcc);
0449     }
0450     bool unscheduledWasNotRun_() const override {
0451       if (realProduct_)
0452         return realProduct_->unscheduledWasNotRun();
0453       throwNullRealProduct();
0454       return false;
0455     }
0456     bool productUnavailable_() const override { return realProduct_->productUnavailable(); }
0457     bool productResolved_() const final { return realProduct_->productResolved(); }
0458     bool productWasDeleted_() const override { return realProduct_->productWasDeleted(); }
0459     bool productWasFetchedAndIsValid_(bool iSkipCurrentProcess) const override {
0460       iSkipCurrentProcess = false;
0461       return realProduct_->productWasFetchedAndIsValid(iSkipCurrentProcess);
0462     }
0463 
0464     BranchDescription const& branchDescription_() const override { return *bd_; }
0465     void resetBranchDescription_(std::shared_ptr<BranchDescription const> bd) override { bd_ = bd; }
0466     Provenance const* provenance_() const final { return realProduct_->provenance(); }
0467     std::string const& resolvedModuleLabel_() const override { return realProduct_->moduleLabel(); }
0468     void setProductProvenanceRetriever_(ProductProvenanceRetriever const* provRetriever) override;
0469     void setProductID_(ProductID const& pid) override;
0470     ProductProvenance const* productProvenancePtr_() const override;
0471     void resetProductData_(bool deleteEarly) override;
0472     bool singleProduct_() const override;
0473     void throwNullRealProduct() const;
0474 
0475     ProductResolverBase const* realProduct_;
0476     std::shared_ptr<BranchDescription const> bd_;
0477     ProductProvenanceRetriever const* provRetriever_;
0478     Principal const* parentPrincipal_;
0479   };
0480 
0481   class NoProcessProductResolver : public ProductResolverBase {
0482   public:
0483     typedef ProducedProductResolver::ProductStatus ProductStatus;
0484     NoProcessProductResolver(std::vector<ProductResolverIndex> const& matchingHolders,
0485                              std::vector<bool> const& ambiguous,
0486                              bool madeAtEnd);
0487 
0488     void connectTo(ProductResolverBase const& iOther, Principal const*) final;
0489 
0490     void tryPrefetchResolverAsync(unsigned int iProcessingIndex,
0491                                   Principal const& principal,
0492                                   bool skipCurrentProcess,
0493                                   SharedResourcesAcquirer* sra,
0494                                   ModuleCallingContext const* mcc,
0495                                   ServiceToken token,
0496                                   oneapi::tbb::task_group*) const;
0497 
0498     bool dataValidFromResolver(unsigned int iProcessingIndex,
0499                                Principal const& principal,
0500                                bool iSkipCurrentProcess) const;
0501 
0502     void prefetchFailed(unsigned int iProcessingIndex,
0503                         Principal const& principal,
0504                         bool iSkipCurrentProcess,
0505                         std::exception_ptr iExceptPtr) const;
0506 
0507   private:
0508     unsigned int unsetIndexValue() const;
0509     Resolution resolveProduct_(Principal const& principal,
0510                                bool skipCurrentProcess,
0511                                SharedResourcesAcquirer* sra,
0512                                ModuleCallingContext const* mcc) const override;
0513     void prefetchAsync_(WaitingTaskHolder waitTask,
0514                         Principal const& principal,
0515                         bool skipCurrentProcess,
0516                         ServiceToken const& token,
0517                         SharedResourcesAcquirer* sra,
0518                         ModuleCallingContext const* mcc) const override;
0519     bool unscheduledWasNotRun_() const override;
0520     bool productUnavailable_() const override;
0521     bool productWasDeleted_() const override;
0522     bool productResolved_() const final;
0523     bool productWasFetchedAndIsValid_(bool iSkipCurrentProcess) const override;
0524 
0525     BranchDescription const& branchDescription_() const override;
0526     void resetBranchDescription_(std::shared_ptr<BranchDescription const> bd) override;
0527     Provenance const* provenance_() const override;
0528 
0529     std::string const& resolvedModuleLabel_() const override { return moduleLabel(); }
0530     void setProductProvenanceRetriever_(ProductProvenanceRetriever const* provRetriever) override;
0531     void setProductID_(ProductID const& pid) override;
0532     ProductProvenance const* productProvenancePtr_() const override;
0533     void resetProductData_(bool deleteEarly) override;
0534     bool singleProduct_() const override;
0535 
0536     Resolution tryResolver(unsigned int index,
0537                            Principal const& principal,
0538                            bool skipCurrentProcess,
0539                            SharedResourcesAcquirer* sra,
0540                            ModuleCallingContext const* mcc) const;
0541 
0542     void setCache(bool skipCurrentProcess, ProductResolverIndex index, std::exception_ptr exceptionPtr) const;
0543 
0544     std::vector<ProductResolverIndex> matchingHolders_;
0545     std::vector<bool> ambiguous_;
0546     CMS_THREAD_SAFE mutable WaitingTaskList waitingTasks_;
0547     CMS_THREAD_SAFE mutable WaitingTaskList skippingWaitingTasks_;
0548     mutable std::atomic<unsigned int> lastCheckIndex_;
0549     mutable std::atomic<unsigned int> lastSkipCurrentCheckIndex_;
0550     mutable std::atomic<bool> prefetchRequested_;
0551     mutable std::atomic<bool> skippingPrefetchRequested_;
0552     const bool madeAtEnd_;
0553   };
0554 
0555   class SingleChoiceNoProcessProductResolver : public ProductResolverBase {
0556   public:
0557     typedef ProducedProductResolver::ProductStatus ProductStatus;
0558     SingleChoiceNoProcessProductResolver(ProductResolverIndex iChoice)
0559         : ProductResolverBase(), realResolverIndex_(iChoice) {}
0560 
0561     void connectTo(ProductResolverBase const& iOther, Principal const*) final;
0562 
0563   private:
0564     Resolution resolveProduct_(Principal const& principal,
0565                                bool skipCurrentProcess,
0566                                SharedResourcesAcquirer* sra,
0567                                ModuleCallingContext const* mcc) const override;
0568     void prefetchAsync_(WaitingTaskHolder waitTask,
0569                         Principal const& principal,
0570                         bool skipCurrentProcess,
0571                         ServiceToken const& token,
0572                         SharedResourcesAcquirer* sra,
0573                         ModuleCallingContext const* mcc) const override;
0574     bool unscheduledWasNotRun_() const override;
0575     bool productUnavailable_() const override;
0576     bool productWasDeleted_() const override;
0577     bool productResolved_() const final;
0578     bool productWasFetchedAndIsValid_(bool iSkipCurrentProcess) const override;
0579 
0580     BranchDescription const& branchDescription_() const override;
0581     void resetBranchDescription_(std::shared_ptr<BranchDescription const> bd) override;
0582     Provenance const* provenance_() const override;
0583 
0584     std::string const& resolvedModuleLabel_() const override { return moduleLabel(); }
0585     void setProductProvenanceRetriever_(ProductProvenanceRetriever const* provRetriever) override;
0586     void setProductID_(ProductID const& pid) override;
0587     ProductProvenance const* productProvenancePtr_() const override;
0588     void resetProductData_(bool deleteEarly) override;
0589     bool singleProduct_() const override;
0590 
0591     ProductResolverIndex realResolverIndex_;
0592   };
0593 
0594 }  // namespace edm
0595 
0596 #endif