File indexing completed on 2024-04-06 12:12:03
0001 #ifndef FWCore_Framework_EventSetupsController_h
0002 #define FWCore_Framework_EventSetupsController_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include "DataFormats/Provenance/interface/ParameterSetID.h"
0022 #include "FWCore/Framework/interface/EventSetupRecordIOVQueue.h"
0023 #include "FWCore/Framework/interface/NumberOfConcurrentIOVs.h"
0024 #include "FWCore/Utilities/interface/propagate_const.h"
0025
0026 #include <map>
0027 #include <memory>
0028 #include <vector>
0029
0030 namespace edm {
0031
0032 class ActivityRegistry;
0033 class EventSetupImpl;
0034 class EventSetupRecordIntervalFinder;
0035 class ParameterSet;
0036 class IOVSyncValue;
0037 class ModuleTypeResolverMaker;
0038 class ServiceToken;
0039 class WaitingTaskHolder;
0040 class WaitingTaskList;
0041
0042 namespace eventsetup {
0043
0044 class ESProductResolverProvider;
0045 class EventSetupProvider;
0046
0047 class ESProducerInfo {
0048 public:
0049 ESProducerInfo(ParameterSet* ps, std::shared_ptr<ESProductResolverProvider> const& pr)
0050 : pset_(ps), provider_(pr), subProcessIndexes_() {}
0051
0052 ParameterSet const* pset() const { return pset_.get(); }
0053 ParameterSet* pset() { return pset_.get(); }
0054 std::shared_ptr<ESProductResolverProvider> const& provider() { return get_underlying(provider_); }
0055 ESProductResolverProvider const* providerGet() const { return provider_.get(); }
0056 std::vector<unsigned>& subProcessIndexes() { return subProcessIndexes_; }
0057 std::vector<unsigned> const& subProcessIndexes() const { return subProcessIndexes_; }
0058
0059 private:
0060 edm::propagate_const<ParameterSet*> pset_;
0061 propagate_const<std::shared_ptr<ESProductResolverProvider>> provider_;
0062 std::vector<unsigned> subProcessIndexes_;
0063 };
0064
0065 class ESSourceInfo {
0066 public:
0067 ESSourceInfo(ParameterSet const* ps, std::shared_ptr<EventSetupRecordIntervalFinder> const& fi)
0068 : pset_(ps), finder_(fi), subProcessIndexes_() {}
0069
0070 ParameterSet const* pset() const { return pset_; }
0071 std::shared_ptr<EventSetupRecordIntervalFinder> const& finder() { return get_underlying(finder_); }
0072 EventSetupRecordIntervalFinder const* finderGet() const { return finder_.get(); }
0073 std::vector<unsigned>& subProcessIndexes() { return subProcessIndexes_; }
0074 std::vector<unsigned> const& subProcessIndexes() const { return subProcessIndexes_; }
0075
0076 private:
0077 ParameterSet const* pset_;
0078 propagate_const<std::shared_ptr<EventSetupRecordIntervalFinder>> finder_;
0079 std::vector<unsigned> subProcessIndexes_;
0080 };
0081
0082 class EventSetupsController {
0083 public:
0084 EventSetupsController();
0085 explicit EventSetupsController(ModuleTypeResolverMaker const* resolverMaker);
0086
0087 EventSetupsController(EventSetupsController const&) = delete;
0088 EventSetupsController const& operator=(EventSetupsController const&) = delete;
0089
0090 void endIOVsAsync(edm::WaitingTaskHolder iEndTask);
0091
0092 std::shared_ptr<EventSetupProvider> makeProvider(ParameterSet&,
0093 ActivityRegistry*,
0094 ParameterSet const* eventSetupPset = nullptr,
0095 unsigned int maxConcurrentIOVs = 0,
0096 bool dumpOptions = false);
0097
0098
0099
0100
0101
0102 void runOrQueueEventSetupForInstanceAsync(IOVSyncValue const&,
0103 WaitingTaskHolder& taskToStartAfterIOVInit,
0104 WaitingTaskList& endIOVWaitingTasks,
0105 std::vector<std::shared_ptr<const EventSetupImpl>>&,
0106 edm::SerialTaskQueue& queueWhichWaitsForIOVsToFinish,
0107 ActivityRegistry*,
0108 ServiceToken const&,
0109 bool iForceCacheClear = false);
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124 void eventSetupForInstanceAsync(IOVSyncValue const&,
0125 WaitingTaskHolder const& taskToStartAfterIOVInit,
0126 WaitingTaskList& endIOVWaitingTasks,
0127 std::vector<std::shared_ptr<const EventSetupImpl>>&);
0128
0129 bool doWeNeedToWaitForIOVsToFinish(IOVSyncValue const&) const;
0130
0131 void forceCacheClear();
0132
0133 std::shared_ptr<ESProductResolverProvider> getESProducerAndRegisterProcess(ParameterSet const& pset,
0134 unsigned subProcessIndex);
0135 void putESProducer(ParameterSet& pset,
0136 std::shared_ptr<ESProductResolverProvider> const& component,
0137 unsigned subProcessIndex);
0138
0139 std::shared_ptr<EventSetupRecordIntervalFinder> getESSourceAndRegisterProcess(ParameterSet const& pset,
0140 unsigned subProcessIndex);
0141 void putESSource(ParameterSet const& pset,
0142 std::shared_ptr<EventSetupRecordIntervalFinder> const& component,
0143 unsigned subProcessIndex);
0144
0145 void finishConfiguration();
0146 void clearComponents();
0147
0148 unsigned indexOfNextProcess() const { return providers_.size(); }
0149
0150 void lookForMatches(ParameterSetID const& psetID,
0151 unsigned subProcessIndex,
0152 unsigned precedingProcessIndex,
0153 bool& firstProcessWithThisPSet,
0154 bool& precedingHasMatchingPSet) const;
0155
0156 bool isFirstMatch(ParameterSetID const& psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const;
0157
0158 bool isLastMatch(ParameterSetID const& psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const;
0159
0160 bool isMatchingESSource(ParameterSetID const& psetID,
0161 unsigned subProcessIndex,
0162 unsigned precedingProcessIndex) const;
0163
0164 bool isMatchingESProducer(ParameterSetID const& psetID,
0165 unsigned subProcessIndex,
0166 unsigned precedingProcessIndex) const;
0167
0168 ParameterSet& getESProducerPSet(ParameterSetID const& psetID, unsigned subProcessIndex);
0169
0170 std::vector<propagate_const<std::shared_ptr<EventSetupProvider>>> const& providers() const { return providers_; }
0171
0172 std::multimap<ParameterSetID, ESProducerInfo> const& esproducers() const { return esproducers_; }
0173
0174 std::multimap<ParameterSetID, ESSourceInfo> const& essources() const { return essources_; }
0175
0176 bool hasNonconcurrentFinder() const { return hasNonconcurrentFinder_; }
0177 bool mustFinishConfiguration() const { return mustFinishConfiguration_; }
0178
0179 private:
0180 void checkESProducerSharing();
0181 void initializeEventSetupRecordIOVQueues();
0182
0183
0184 std::vector<propagate_const<std::shared_ptr<EventSetupProvider>>> providers_;
0185 NumberOfConcurrentIOVs numberOfConcurrentIOVs_;
0186
0187
0188
0189 std::vector<propagate_const<std::unique_ptr<EventSetupRecordIOVQueue>>> eventSetupRecordIOVQueues_;
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201 std::multimap<ParameterSetID, ESProducerInfo> esproducers_;
0202 std::multimap<ParameterSetID, ESSourceInfo> essources_;
0203
0204 ModuleTypeResolverMaker const* typeResolverMaker_ = nullptr;
0205
0206 bool hasNonconcurrentFinder_ = false;
0207 bool mustFinishConfiguration_ = true;
0208 };
0209
0210 void synchronousEventSetupForInstance(IOVSyncValue const& syncValue,
0211 oneapi::tbb::task_group& iGroup,
0212 eventsetup::EventSetupsController& espController);
0213 }
0214 }
0215 #endif