Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-22 01:53:27

0001 #ifndef FWCore_Framework_ESSourceDataProxyNonConcurrentBase_h
0002 #define FWCore_Framework_ESSourceDataProxyNonConcurrentBase_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     FWCore/Framework
0006 // Class  :     ESSourceDataProxyNonConcurrentBase
0007 //
0008 /**\class ESSourceDataProxyNonConcurrentBase ESSourceDataProxyNonConcurrentBase.h "FWCore/Framework/interface/ESSourceDataProxyNonConcurrentBase.h"
0009 
0010  Description: Base class for DataProxies for ESSources that require synchronization
0011 
0012  Usage:
0013     The ESSourceDataProxyNonConcurrentBase uses a SerialTaskQueue to serialize all DataProxies for the ESSource and a
0014     std::mutex to protect from concurrent calls to a DataProxy and the ESSource itself. Such concurrent calls
0015     can happen if concurrent LuminosityBlocks are being used.
0016 
0017     NOTE: if inheriting classes override `void invalidateCache()` they must be sure to call this classes
0018     implementation as part of the call.
0019 
0020 */
0021 //
0022 // Original Author:  Chris Jones
0023 //         Created:  14/05/2020
0024 //
0025 
0026 // system include files
0027 #include <mutex>
0028 
0029 // user include files
0030 #include "FWCore/Framework/interface/ESSourceDataProxyBase.h"
0031 #include "FWCore/Concurrency/interface/SerialTaskQueue.h"
0032 
0033 // forward declarations
0034 
0035 namespace edm::eventsetup {
0036   class ESSourceDataProxyNonConcurrentBase : public ESSourceDataProxyBase {
0037   public:
0038     ESSourceDataProxyNonConcurrentBase(edm::SerialTaskQueue* iQueue, std::mutex* iMutex)
0039         : m_queue(iQueue), m_mutex(iMutex) {}
0040 
0041     edm::SerialTaskQueue* queue() const { return m_queue; }
0042     std::mutex* mutex() const { return m_mutex; }
0043 
0044   private:
0045     void prefetchAsyncImpl(edm::WaitingTaskHolder iTask,
0046                            edm::eventsetup::EventSetupRecordImpl const& iES,
0047                            edm::eventsetup::DataKey const& iKey,
0048                            edm::EventSetupImpl const*,
0049                            edm::ServiceToken const&,
0050                            edm::ESParentContext const&) final;
0051 
0052     // ---------- member data --------------------------------
0053 
0054     edm::SerialTaskQueue* m_queue;
0055     std::mutex* m_mutex;
0056   };
0057 }  // namespace edm::eventsetup
0058 #endif