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 
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
87  moduleRan(iEvent);
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 //
void appendIndex(unsigned int index)
std::atomic< unsigned int > pathsLeftToComplete_
EarlyDeleteHelper(unsigned int *iBeginIndexItr, unsigned int *iEndIndexItr, std::vector< BranchToCount > *iBranchCounts)
int iEvent
Definition: GenABIO.cc:224
unsigned int * pBeginIndex_
Definition: value.py:1
void moduleRan(EventPrincipal const &)
std::vector< BranchToCount > * pBranchCounts_
def load(fileName)
Definition: svgfig.py:547
void pathFinished(EventPrincipal const &)
HLT enums.
void shiftIndexPointers(unsigned int iShift)
void deleteProduct(BranchID const &id) const
Definition: Principal.cc:384