CMS 3D CMS Logo

PrincipalCache.cc
Go to the documentation of this file.
2 
8 
9 #include <cassert>
10 
11 namespace edm {
12 
14 
16 
17  std::shared_ptr<RunPrincipal> PrincipalCache::getAvailableRunPrincipalPtr() { return runHolder_.tryToGet(); }
18 
19  std::shared_ptr<LuminosityBlockPrincipal> PrincipalCache::getAvailableLumiPrincipalPtr() {
20  return lumiHolder_.tryToGet();
21  }
22 
24  eventPrincipals_.resize(iConfig.numberOfStreams());
25  }
26 
27  void PrincipalCache::insert(std::unique_ptr<ProcessBlockPrincipal> pb) { processBlockPrincipal_ = std::move(pb); }
28 
29  void PrincipalCache::insertForInput(std::unique_ptr<ProcessBlockPrincipal> pb) {
31  }
32 
33  void PrincipalCache::insert(std::unique_ptr<RunPrincipal> rp) { runHolder_.add(std::move(rp)); }
34 
35  void PrincipalCache::insert(std::unique_ptr<LuminosityBlockPrincipal> lbp) { lumiHolder_.add(std::move(lbp)); }
36 
37  void PrincipalCache::insert(std::shared_ptr<EventPrincipal> ep) {
38  unsigned int iStreamIndex = ep->streamID().value();
39  assert(iStreamIndex < eventPrincipals_.size());
40  eventPrincipals_[iStreamIndex] = ep;
41  }
42 
43  void PrincipalCache::adjustEventsToNewProductRegistry(std::shared_ptr<ProductRegistry const> reg) {
44  for (auto& eventPrincipal : eventPrincipals_) {
45  if (eventPrincipal) {
47  bool eventOK = eventPrincipal->adjustToNewProductRegistry(*reg);
48  assert(eventOK);
49  }
50  }
51  }
52 
54  //Need to temporarily hold all the runs to clear out the runHolder_
55  std::vector<std::shared_ptr<RunPrincipal>> tempRunPrincipals;
56  while (auto p = runHolder_.tryToGet()) {
57  p->adjustIndexesAfterProductRegistryAddition();
58  tempRunPrincipals.emplace_back(std::move(p));
59  }
60  //Need to temporarily hold all the lumis to clear out the lumiHolder_
61  std::vector<std::shared_ptr<LuminosityBlockPrincipal>> tempLumiPrincipals;
62  while (auto p = lumiHolder_.tryToGet()) {
63  p->adjustIndexesAfterProductRegistryAddition();
64  tempLumiPrincipals.emplace_back(std::move(p));
65  }
66  }
67 
68 } // namespace edm
std::unique_ptr< ProcessBlockPrincipal > processBlockPrincipal_
void setNumberOfConcurrentPrincipals(PreallocationConfiguration const &)
edm::ReusableObjectHolder< RunPrincipal > runHolder_
std::shared_ptr< RunPrincipal > getAvailableRunPrincipalPtr()
void adjustEventsToNewProductRegistry(std::shared_ptr< ProductRegistry const >)
void adjustIndexesAfterProductRegistryAddition()
assert(be >=bs)
std::unique_ptr< ProcessBlockPrincipal > inputProcessBlockPrincipal_
edm::ReusableObjectHolder< LuminosityBlockPrincipal > lumiHolder_
std::vector< std::shared_ptr< EventPrincipal > > eventPrincipals_
void insert(std::unique_ptr< ProcessBlockPrincipal >)
void insertForInput(std::unique_ptr< ProcessBlockPrincipal >)
EventPrincipal & eventPrincipal(unsigned int iStreamIndex) const
HLT enums.
bool adjustToNewProductRegistry(ProductRegistry const &reg)
Definition: Principal.cc:315
std::shared_ptr< LuminosityBlockPrincipal > getAvailableLumiPrincipalPtr()
void adjustIndexesAfterProductRegistryAddition()
Definition: Principal.cc:877
def move(src, dest)
Definition: eostools.py:511