Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:27:49

0001 #ifndef FWCore_Framework_SharedResourcesAcquirer_h
0002 #define FWCore_Framework_SharedResourcesAcquirer_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     FWCore/Framework
0006 // Class  :     SharedResourcesAcquirer
0007 //
0008 /**\class SharedResourcesAcquirer SharedResourcesAcquirer.h "SharedResourcesAcquirer.h"
0009 
0010  Description: Handles acquiring and releasing a group of resources shared between modules
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Sun, 06 Oct 2013 19:43:26 GMT
0019 //
0020 
0021 // system include files
0022 #include "FWCore/Concurrency/interface/SerialTaskQueueChain.h"
0023 #include "FWCore/Utilities/interface/thread_safety_macros.h"
0024 
0025 // user include files
0026 
0027 // forward declarations
0028 class testSharedResourcesRegistry;
0029 
0030 namespace edm {
0031   class SerialTaskQueueChain;
0032   class SerialTaskQueue;
0033 
0034   class SharedResourcesAcquirer {
0035   public:
0036     friend class ::testSharedResourcesRegistry;
0037 
0038     SharedResourcesAcquirer() = default;
0039     explicit SharedResourcesAcquirer(std::vector<std::shared_ptr<SerialTaskQueue>> iQueues)
0040         : m_queues(std::move(iQueues)) {}
0041 
0042     SharedResourcesAcquirer(SharedResourcesAcquirer&&) = default;
0043     SharedResourcesAcquirer(const SharedResourcesAcquirer&) = delete;
0044     SharedResourcesAcquirer& operator=(const SharedResourcesAcquirer&) = delete;
0045 
0046     SharedResourcesAcquirer& operator=(SharedResourcesAcquirer&&) = default;
0047     ~SharedResourcesAcquirer() = default;
0048 
0049     // ---------- member functions ---------------------------
0050 
0051     ///The number returned may be less than the number of resources requested if a resource is only used by one module and therefore is not being shared.
0052     size_t numberOfResources() const { return m_queues.numberOfQueues(); }
0053 
0054     SerialTaskQueueChain& serialQueueChain() const { return m_queues; }
0055 
0056   private:
0057     // ---------- member data --------------------------------
0058     //The class is thread safe even for non const functions
0059     CMS_THREAD_SAFE mutable SerialTaskQueueChain m_queues;
0060   };
0061 }  // namespace edm
0062 
0063 #endif