Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef FWCore_Framework_EventSetupRecordIOVQueue_h
0002 #define FWCore_Framework_EventSetupRecordIOVQueue_h
0003 
0004 // -*- C++ -*-
0005 //
0006 // Package:     Framework
0007 // Class  :     EventSetupRecordIOVQueue
0008 //
0009 /** \class edm::eventsetup::EventSetupRecordIOVQueue
0010 
0011  Description: Contains a LimitedQueue for each Record that
0012  limits the number of IOVs that can be processed concurrently.
0013  Also contains data closely related to starting and
0014  stopping those IOVs.
0015 
0016  This manages creating the TBB tasks that start and end IOVs.
0017  It creates those tasks. It ensures those tasks wait until
0018  the proper time to start and notify the proper other tasks
0019  when done.
0020 
0021  It protects the many EventSetupRecordImpl's from data races
0022  by ensuring that while multiple threads are using them
0023  concurrently only thread safe functions are being called.
0024 
0025 */
0026 //
0027 // Original Author: W. David Dagenhart
0028 //          Created: 22 Feb 2019
0029 //
0030 
0031 #include "FWCore/Concurrency/interface/LimitedTaskQueue.h"
0032 #include "FWCore/Concurrency/interface/WaitingTaskHolder.h"
0033 #include "FWCore/Concurrency/interface/WaitingTaskList.h"
0034 #include "FWCore/Utilities/interface/propagate_const.h"
0035 
0036 #include <atomic>
0037 #include <memory>
0038 #include <vector>
0039 
0040 namespace edm {
0041   namespace eventsetup {
0042 
0043     class EventSetupRecordProvider;
0044 
0045     class EventSetupRecordIOVQueue {
0046     public:
0047       EventSetupRecordIOVQueue(unsigned int nConcurrentIOVs);
0048       ~EventSetupRecordIOVQueue();
0049 
0050       void endIOVAsync(WaitingTaskHolder endTask);
0051 
0052       void setNewIntervalForAnySubProcess();
0053 
0054       void checkForNewIOVs(WaitingTaskHolder const& taskToStartAfterIOVInit,
0055                            WaitingTaskList& endIOVWaitingTasks,
0056                            bool newEventSetupImpl);
0057 
0058       void startNewIOVAsync(WaitingTaskHolder const& taskToStartAfterIOVInit, WaitingTaskList& endIOVWaitingTasks);
0059 
0060       void addRecProvider(EventSetupRecordProvider* recProvider);
0061 
0062     private:
0063       // Used to limit the number of concurrent IOVs
0064       edm::LimitedTaskQueue iovQueue_;
0065       edm::WaitingTaskList endIOVTasks_;
0066 
0067       // Each element of this vector corresponds to one IOV
0068       // out the set of possible concurrent IOVs.
0069       std::vector<std::atomic<bool>> isAvailable_;
0070 
0071       // Unless there are SubProcesses this vector will have only 1 element
0072       std::vector<edm::propagate_const<EventSetupRecordProvider*>> recordProviders_;
0073 
0074       // These are associated with the most recent iov.
0075       unsigned long long cacheIdentifier_;
0076       WaitingTaskHolder endIOVTaskHolder_;
0077       bool endIOVCalled_ = false;
0078     };
0079 
0080   }  // namespace eventsetup
0081 }  // namespace edm
0082 #endif