Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:14

0001 // -*- C++ -*-
0002 //
0003 // Package:     FWCore/Framework
0004 // Class  :     RecordDependencyRegister
0005 //
0006 // Implementation:
0007 //     [Notes on implementation]
0008 //
0009 // Original Author:  root
0010 //         Created:  Thu, 26 Apr 2018 16:03:47 GMT
0011 //
0012 
0013 // system include files
0014 #include "oneapi/tbb/concurrent_unordered_map.h"
0015 
0016 // user include files
0017 #include "FWCore/Framework/interface/RecordDependencyRegister.h"
0018 
0019 namespace edm {
0020   namespace eventsetup {
0021     namespace {
0022       struct KeyHash {
0023         std::size_t operator()(EventSetupRecordKey const& iKey) const { return iKey.type().value().hash_code(); }
0024       };
0025 
0026       oneapi::tbb::concurrent_unordered_map<EventSetupRecordKey, DepFunction, KeyHash>& getMap() {
0027         static oneapi::tbb::concurrent_unordered_map<EventSetupRecordKey, DepFunction, KeyHash> s_map;
0028         return s_map;
0029       }
0030 
0031       oneapi::tbb::concurrent_unordered_map<EventSetupRecordKey, bool, KeyHash>& getAllowMap() {
0032         static oneapi::tbb::concurrent_unordered_map<EventSetupRecordKey, bool, KeyHash> s_allow_map;
0033         return s_allow_map;
0034       }
0035     }  // namespace
0036 
0037     std::set<EventSetupRecordKey> dependencies(EventSetupRecordKey const& iKey) {
0038       auto& map = getMap();
0039       auto itFind = map.find(iKey);
0040       if (itFind != map.end()) {
0041         return itFind->second();
0042       }
0043       return std::set<EventSetupRecordKey>();
0044     }
0045 
0046     bool allowConcurrentIOVs(EventSetupRecordKey const& iKey) {
0047       auto& map = getAllowMap();
0048       auto itFind = map.find(iKey);
0049       if (itFind != map.end()) {
0050         return itFind->second;
0051       }
0052       return false;
0053     }
0054 
0055     void addDependencyFunction(EventSetupRecordKey iKey, DepFunction iFunction, bool allowConcurrentIOVs) {
0056       getMap().emplace(iKey, iFunction);
0057       getAllowMap().emplace(iKey, allowConcurrentIOVs);
0058     }
0059 
0060   }  // namespace eventsetup
0061 }  // namespace edm