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 {
42 }
43 
50 {
51 
52 }
53 
54 //EarlyDeleteHelper::~EarlyDeleteHelper()
55 //{
56 //}
57 
58 //
59 // assignment operators
60 //
61 // const EarlyDeleteHelper& EarlyDeleteHelper::operator=(const EarlyDeleteHelper& rhs)
62 // {
63 // //An exception safe implementation is
64 // EarlyDeleteHelper temp(rhs);
65 // swap(rhs);
66 //
67 // return *this;
68 // }
69 
70 //
71 // member functions
72 //
73 void
76  for(auto it = pBeginIndex_; it != pEndIndex_;++it) {
77  auto& count = (*pBranchCounts_)[*it];
78  assert(count.count>0);
79  auto value = --(count.count);
80  if(value==0) {
81  iEvent.deleteProduct(count.branch);
82  }
83  }
84 }
85 
86 void
88  unsigned int value = pathsLeftToComplete_;
89  while(value > 0) {
90  if( pathsLeftToComplete_.compare_exchange_strong(value, value-1)) {
91  //we were the thread that changed the value
92  if( value == 1) {
93  //we can never reach this module now so declare it as run
94  moduleRan(iEvent);
95  }
96  break;
97  }
98  }
99 }
100 
101 void
102 EarlyDeleteHelper::appendIndex(unsigned int iIndex) {
103  *pEndIndex_=iIndex;
104  ++pEndIndex_;
105 }
106 
107 void
109  pEndIndex_ -=iShift;
110  pBeginIndex_ -=iShift;
111 }
112 
113 //
114 // const member functions
115 //
116 
117 //
118 // static member functions
119 //
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:230
unsigned int * pBeginIndex_
Definition: value.py:1
void moduleRan(EventPrincipal const &)
std::vector< BranchToCount > * pBranchCounts_
def load(fileName)
Definition: svgfig.py:546
void pathFinished(EventPrincipal const &)
HLT enums.
void shiftIndexPointers(unsigned int iShift)
void deleteProduct(BranchID const &id) const
Definition: Principal.cc:351