File indexing completed on 2024-04-06 12:12:08
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "DataFormats/Provenance/interface/BranchID.h"
0017 #include "FWCore/Framework/interface/EventPrincipal.h"
0018
0019 #include "FWCore/Framework/interface/EarlyDeleteHelper.h"
0020
0021 using namespace edm;
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 EarlyDeleteHelper::EarlyDeleteHelper(unsigned int* iBeginIndexItr,
0034 unsigned int* iEndIndexItr,
0035 std::vector<BranchToCount>* iBranchCounts)
0036 : pBeginIndex_(iBeginIndexItr),
0037 pEndIndex_(iEndIndexItr),
0038 pBranchCounts_(iBranchCounts),
0039 pathsLeftToComplete_(0),
0040 nPathsOn_(0) {}
0041
0042 EarlyDeleteHelper::EarlyDeleteHelper(const EarlyDeleteHelper& rhs)
0043 : pBeginIndex_(rhs.pBeginIndex_),
0044 pEndIndex_(rhs.pEndIndex_),
0045 pBranchCounts_(rhs.pBranchCounts_),
0046 pathsLeftToComplete_(rhs.pathsLeftToComplete_.load()),
0047 nPathsOn_(rhs.nPathsOn_) {}
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068 void EarlyDeleteHelper::moduleRan(EventPrincipal const& iEvent) {
0069 pathsLeftToComplete_ = 0;
0070 for (auto it = pBeginIndex_; it != pEndIndex_; ++it) {
0071 auto& count = (*pBranchCounts_)[*it];
0072 assert(count.count > 0);
0073 auto value = --(count.count);
0074 if (value == 0) {
0075 iEvent.deleteProduct(count.branch);
0076 }
0077 }
0078 }
0079
0080 void EarlyDeleteHelper::pathFinished(EventPrincipal const& iEvent) {
0081 unsigned int value = pathsLeftToComplete_;
0082 while (value > 0) {
0083 if (pathsLeftToComplete_.compare_exchange_strong(value, value - 1)) {
0084
0085 if (value == 1) {
0086
0087 moduleRan(iEvent);
0088 }
0089 break;
0090 }
0091 }
0092 }
0093
0094 void EarlyDeleteHelper::appendIndex(unsigned int iIndex) {
0095 *pEndIndex_ = iIndex;
0096 ++pEndIndex_;
0097 }
0098
0099 void EarlyDeleteHelper::shiftIndexPointers(unsigned int iShift) {
0100 pEndIndex_ -= iShift;
0101 pBeginIndex_ -= iShift;
0102 }
0103
0104
0105
0106
0107
0108
0109
0110