CMS 3D CMS Logo

EarlyDeleteHelper.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Framework
4 // Class : EarlyDeleteHelper
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Chris Jones
10 // Created: Mon Feb 6 16:17:10 CST 2012
11 //
12 
13 // system include files
14 
15 // user include files
18 
20 
21 using namespace edm;
22 //
23 // constants, enums and typedefs
24 //
25 
26 //
27 // static data member definitions
28 //
29 
30 //
31 // constructors and destructor
32 //
33 EarlyDeleteHelper::EarlyDeleteHelper(unsigned int* iBeginIndexItr,
34  unsigned int* iEndIndexItr,
35  std::vector<BranchToCount>* iBranchCounts)
36  : pBeginIndex_(iBeginIndexItr),
37  pEndIndex_(iEndIndexItr),
38  pBranchCounts_(iBranchCounts),
39  pathsLeftToComplete_(0),
40  nPathsOn_(0) {}
41 
43  : pBeginIndex_(rhs.pBeginIndex_),
44  pEndIndex_(rhs.pEndIndex_),
45  pBranchCounts_(rhs.pBranchCounts_),
46  pathsLeftToComplete_(rhs.pathsLeftToComplete_.load()),
47  nPathsOn_(rhs.nPathsOn_) {}
48 
49 //EarlyDeleteHelper::~EarlyDeleteHelper()
50 //{
51 //}
52 
53 //
54 // assignment operators
55 //
56 // const EarlyDeleteHelper& EarlyDeleteHelper::operator=(const EarlyDeleteHelper& rhs)
57 // {
58 // //An exception safe implementation is
59 // EarlyDeleteHelper temp(rhs);
60 // swap(rhs);
61 //
62 // return *this;
63 // }
64 
65 //
66 // member functions
67 //
70  for (auto it = pBeginIndex_; it != pEndIndex_; ++it) {
71  auto& count = (*pBranchCounts_)[*it];
72  assert(count.count > 0);
73  auto value = --(count.count);
74  if (value == 0) {
75  iEvent.deleteProduct(count.branch);
76  }
77  }
78 }
79 
81  unsigned int value = pathsLeftToComplete_;
82  while (value > 0) {
83  if (pathsLeftToComplete_.compare_exchange_strong(value, value - 1)) {
84  //we were the thread that changed the value
85  if (value == 1) {
86  //we can never reach this module now so declare it as run
88  }
89  break;
90  }
91  }
92 }
93 
94 void EarlyDeleteHelper::appendIndex(unsigned int iIndex) {
95  *pEndIndex_ = iIndex;
96  ++pEndIndex_;
97 }
98 
99 void EarlyDeleteHelper::shiftIndexPointers(unsigned int iShift) {
100  pEndIndex_ -= iShift;
101  pBeginIndex_ -= iShift;
102 }
103 
104 //
105 // const member functions
106 //
107 
108 //
109 // static member functions
110 //
edm::EarlyDeleteHelper::moduleRan
void moduleRan(EventPrincipal const &)
Definition: EarlyDeleteHelper.cc:68
edm::EarlyDeleteHelper::pathsLeftToComplete_
std::atomic< unsigned int > pathsLeftToComplete_
Definition: EarlyDeleteHelper.h:69
edm
HLT enums.
Definition: AlignableModifier.h:19
BranchID.h
edm::EarlyDeleteHelper::pathFinished
void pathFinished(EventPrincipal const &)
Definition: EarlyDeleteHelper.cc:80
cms::cuda::assert
assert(be >=bs)
edm::EarlyDeleteHelper::shiftIndexPointers
void shiftIndexPointers(unsigned int iShift)
Definition: EarlyDeleteHelper.cc:99
edm::EventPrincipal
Definition: EventPrincipal.h:48
EarlyDeleteHelper.h
EventPrincipal.h
edm::EarlyDeleteHelper::pEndIndex_
unsigned int * pEndIndex_
Definition: EarlyDeleteHelper.h:67
svgfig.load
def load(fileName)
Definition: svgfig.py:547
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
iEvent
int iEvent
Definition: GenABIO.cc:224
value
Definition: value.py:1
edm::EarlyDeleteHelper::appendIndex
void appendIndex(unsigned int index)
Definition: EarlyDeleteHelper.cc:94
edm::EarlyDeleteHelper
Definition: EarlyDeleteHelper.h:40
edm::EarlyDeleteHelper::pBeginIndex_
unsigned int * pBeginIndex_
Definition: EarlyDeleteHelper.h:66
edm::EarlyDeleteHelper::EarlyDeleteHelper
EarlyDeleteHelper(unsigned int *iBeginIndexItr, unsigned int *iEndIndexItr, std::vector< BranchToCount > *iBranchCounts)
Definition: EarlyDeleteHelper.cc:33