Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef FWCore_Framework_EarlyDeleteHelper_h
0002 #define FWCore_Framework_EarlyDeleteHelper_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     Framework
0006 // Class  :     EarlyDeleteHelper
0007 //
0008 /**\class EarlyDeleteHelper EarlyDeleteHelper.h FWCore/Framework/interface/EarlyDeleteHelper.h
0009 
0010  Description: [one line class summary]
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Mon Feb  6 16:17:08 CST 2012
0019 //
0020 
0021 // system include files
0022 #include <vector>
0023 #include <atomic>
0024 
0025 // user include files
0026 #include "DataFormats/Provenance/interface/BranchID.h"
0027 // forward declarations
0028 namespace edm {
0029   class EventPrincipal;
0030 
0031   struct BranchToCount {
0032     edm::BranchID const branch;
0033     std::atomic<unsigned int> count;
0034 
0035     BranchToCount(edm::BranchID id, unsigned int count) : branch(id), count(count) {}
0036 
0037     BranchToCount(BranchToCount const& iOther) : branch(iOther.branch), count(iOther.count.load()) {}
0038   };
0039 
0040   class EarlyDeleteHelper {
0041   public:
0042     EarlyDeleteHelper(unsigned int* iBeginIndexItr,
0043                       unsigned int* iEndIndexItr,
0044                       std::vector<BranchToCount>* iBranchCounts);
0045     EarlyDeleteHelper(const EarlyDeleteHelper&);
0046     EarlyDeleteHelper& operator=(const EarlyDeleteHelper&) = delete;
0047     //virtual ~EarlyDeleteHelper();
0048 
0049     // ---------- const member functions ---------------------
0050 
0051     // ---------- static member functions --------------------
0052 
0053     // ---------- member functions ---------------------------
0054     void reset() { pathsLeftToComplete_ = nPathsOn_; }
0055     void moduleRan(EventPrincipal const&);
0056     void pathFinished(EventPrincipal const&);
0057     void addedToPath() { ++nPathsOn_; }
0058     void appendIndex(unsigned int index);
0059     void shiftIndexPointers(unsigned int iShift);
0060 
0061     unsigned int* begin() { return pBeginIndex_; }
0062     unsigned int* end() { return pEndIndex_; }
0063 
0064   private:
0065     // ---------- member data --------------------------------
0066     unsigned int* pBeginIndex_;
0067     unsigned int* pEndIndex_;
0068     std::vector<BranchToCount>* pBranchCounts_;
0069     std::atomic<unsigned int> pathsLeftToComplete_;
0070     unsigned int nPathsOn_;
0071   };
0072 }  // namespace edm
0073 
0074 #endif