File indexing completed on 2024-04-06 12:12:01
0001 #ifndef FWCore_Framework_EarlyDeleteHelper_h
0002 #define FWCore_Framework_EarlyDeleteHelper_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include <vector>
0023 #include <atomic>
0024
0025
0026 #include "DataFormats/Provenance/interface/BranchID.h"
0027
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
0048
0049
0050
0051
0052
0053
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
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 }
0073
0074 #endif