diff --git a/FWCore/Framework/interface/EventSetupProvider.h b/FWCore/Framework/interface/EventSetupProvider.h index 96673e672500d..a1960604921cf 100644 --- a/FWCore/Framework/interface/EventSetupProvider.h +++ b/FWCore/Framework/interface/EventSetupProvider.h @@ -96,6 +96,8 @@ namespace edm { std::map>& referencedESProducers, EventSetupsController& esController); + void updateLookup(); + bool doRecordsMatch(EventSetupProvider& precedingESProvider, EventSetupRecordKey const& eventSetupRecordKey, std::map& allComponentsMatch, diff --git a/FWCore/Framework/interface/EventSetupRecordProvider.h b/FWCore/Framework/interface/EventSetupRecordProvider.h index a1891dede5f6f..7c426715fa701 100644 --- a/FWCore/Framework/interface/EventSetupRecordProvider.h +++ b/FWCore/Framework/interface/EventSetupRecordProvider.h @@ -23,6 +23,7 @@ #include "FWCore/Framework/interface/EventSetupRecordImpl.h" #include "FWCore/Framework/interface/ValidityInterval.h" #include "FWCore/Utilities/interface/get_underlying_safe.h" +#include "FWCore/Utilities/interface/propagate_const.h" // system include files #include @@ -40,6 +41,7 @@ namespace edm { struct ComponentDescription; class DataKey; class ESProductResolverProvider; + class ESRecordsToProductResolverIndices; class EventSetupProvider; class EventSetupRecordImpl; class ParameterSetIDHolder; @@ -157,6 +159,8 @@ namespace edm { IntervalStatus intervalStatus() const { return intervalStatus_; } + void updateLookup(ESRecordsToProductResolverIndices const&); + protected: void addResolversToRecordHelper(edm::propagate_const>& dpp, DataToPreferredProviderMap const& mp) { diff --git a/FWCore/Framework/src/ESProducer.cc b/FWCore/Framework/src/ESProducer.cc index 234e7fd7b02c6..eee94fe0eec84 100644 --- a/FWCore/Framework/src/ESProducer.cc +++ b/FWCore/Framework/src/ESProducer.cc @@ -28,13 +28,13 @@ namespace edm { sharedResourceNames_.reset(); } - itemsToGetFromRecords_.reserve(consumesInfos_.size()); - recordsUsedDuringGet_.reserve(consumesInfos_.size()); - if (itemsToGetFromRecords_.size() == consumesInfos_.size()) { return; } + itemsToGetFromRecords_.reserve(consumesInfos_.size()); + recordsUsedDuringGet_.reserve(consumesInfos_.size()); + for (auto& info : consumesInfos_) { auto& items = itemsToGetFromRecords_.emplace_back(); items.reserve(info->size()); diff --git a/FWCore/Framework/src/EventSetupProvider.cc b/FWCore/Framework/src/EventSetupProvider.cc index 6b3165f183eef..f747a130ff756 100644 --- a/FWCore/Framework/src/EventSetupProvider.cc +++ b/FWCore/Framework/src/EventSetupProvider.cc @@ -347,10 +347,6 @@ namespace edm { } } - auto indices = recordsToResolverIndices(); - for (auto& provider : *dataProviders_) { - provider->updateLookup(indices); - } dataProviders_.reset(); mustFinishConfiguration_ = false; @@ -541,6 +537,13 @@ namespace edm { } } + void EventSetupProvider::updateLookup() { + auto indices = recordsToResolverIndices(); + for (auto& recordProvider : recordProviders_) { + recordProvider->updateLookup(indices); + } + } + bool EventSetupProvider::doRecordsMatch(EventSetupProvider& precedingESProvider, EventSetupRecordKey const& eventSetupRecordKey, std::map& allComponentsMatch, diff --git a/FWCore/Framework/src/EventSetupRecordProvider.cc b/FWCore/Framework/src/EventSetupRecordProvider.cc index 5daa14824bcb8..25597a8e3957a 100644 --- a/FWCore/Framework/src/EventSetupRecordProvider.cc +++ b/FWCore/Framework/src/EventSetupRecordProvider.cc @@ -252,6 +252,12 @@ namespace edm { for_all(providers_, std::bind(&EventSetupRecordProvider::addResolversToRecordHelper, this, _1, iMap)); } + void EventSetupRecordProvider::updateLookup(ESRecordsToProductResolverIndices const& iResolverToIndices) { + for (auto& productResolverProvider : providers_) { + productResolverProvider->updateLookup(iResolverToIndices); + } + } + std::set EventSetupRecordProvider::dependentRecords() const { return dependencies(key()); } std::set EventSetupRecordProvider::resolverProviderDescriptions() const { diff --git a/FWCore/Framework/src/EventSetupsController.cc b/FWCore/Framework/src/EventSetupsController.cc index 3f6873a7db37b..1947cfd7979a8 100644 --- a/FWCore/Framework/src/EventSetupsController.cc +++ b/FWCore/Framework/src/EventSetupsController.cc @@ -87,9 +87,17 @@ namespace edm { // In the following function, all the other components that contribute // to the same record and also the records that record depends on are // also checked. The component sharing is appropriately fixed as necessary. + // (this needs to be done before updateLookup because this can cause new + // ESProducers to be constructed). checkESProducerSharing(); clearComponents(); + // updateLookup needs to be called after checkESProducerSharing because + // that can cause new ESProducers to be constructed + for (auto& eventSetupProvider : providers_) { + eventSetupProvider->updateLookup(); + } + initializeEventSetupRecordIOVQueues(); numberOfConcurrentIOVs_.clear(); mustFinishConfiguration_ = false;