CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
edm::InputProductResolver Class Reference

#include <ProductResolvers.h>

Inheritance diagram for edm::InputProductResolver:
edm::DataManagingProductResolver edm::ProductResolverBase

Public Member Functions

 InputProductResolver (std::shared_ptr< BranchDescription const > bd)
 
void setupUnscheduled (UnscheduledConfigurator const &) final
 
- Public Member Functions inherited from edm::DataManagingProductResolver
void connectTo (ProductResolverBase const &, Principal const *) final
 
 DataManagingProductResolver (std::shared_ptr< BranchDescription const > bd, ProductStatus iDefaultStatus)
 
void resetStatus ()
 
template<bool callResolver, typename FUNC >
ProductResolverBase::Resolution resolveProductImpl (FUNC resolver) const
 
- Public Member Functions inherited from edm::ProductResolverBase
BranchDescription const & branchDescription () const
 
std::string const & moduleLabel () const
 
ProductResolverBaseoperator= (ProductResolverBase const &)=delete
 
void prefetchAsync (WaitingTask *waitTask, Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
 
std::string const & processName () const
 
ProductID const & productID () const
 
std::string const & productInstanceName () const
 
ProductProvenance const * productProvenancePtr () const
 
bool productResolved () const
 
 ProductResolverBase ()
 
 ProductResolverBase (ProductResolverBase const &)=delete
 
TypeID productType () const
 
bool productUnavailable () const
 
bool productWasDeleted () const
 
bool productWasFetchedAndIsValid (bool iSkipCurrentProcess) const
 
Provenance const * provenance () const
 
bool provenanceAvailable () const
 
void putOrMergeProduct (std::unique_ptr< WrapperBase > edp) const
 
void putProduct (std::unique_ptr< WrapperBase > edp) const
 
void resetBranchDescription (std::shared_ptr< BranchDescription const > bd)
 
virtual void resetFailedFromThisProcess ()
 
void resetProductData ()
 
std::string const & resolvedModuleLabel () const
 
Resolution resolveProduct (Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
 
void retrieveAndMerge (Principal const &principal) const
 
void setProcessHistory (ProcessHistory const &ph)
 
void setProvenance (ProductProvenanceRetriever const *provRetriever, ProcessHistory const &ph, ProductID const &pid)
 
bool singleProduct () const
 
StableProvenance const * stableProvenance () const
 
void unsafe_deleteProduct () const
 
bool unscheduledWasNotRun () const
 
void write (std::ostream &os) const
 
virtual ~ProductResolverBase ()
 

Private Member Functions

bool isFromCurrentProcess () const final
 
void prefetchAsync_ (WaitingTask *waitTask, Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const override
 
void putProduct_ (std::unique_ptr< WrapperBase > edp) const override
 
void resetProductData_ (bool deleteEarly) override
 
Resolution resolveProduct_ (Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const override
 
void retrieveAndMerge_ (Principal const &principal) const override
 
bool unscheduledWasNotRun_ () const final
 

Private Attributes

UnscheduledAuxiliary const * aux_
 
std::atomic< bool > m_prefetchRequested
 
WaitingTaskList m_waitingTasks
 

Additional Inherited Members

- Public Types inherited from edm::DataManagingProductResolver
enum  ProductStatus {
  ProductStatus::ProductSet, ProductStatus::NotPut, ProductStatus::ResolveFailed, ProductStatus::ResolveNotRun,
  ProductStatus::ProductDeleted
}
 
- Protected Member Functions inherited from edm::DataManagingProductResolver
ProductStatus defaultStatus () const
 
template<bool callResolver, typename FUNC >
Resolution resolveProductImpl (FUNC resolver) const
 
void setFailedStatus () const
 
void setProduct (std::unique_ptr< WrapperBase > edp) const
 
ProductStatus status () const
 

Detailed Description

Definition at line 96 of file ProductResolvers.h.

Constructor & Destructor Documentation

edm::InputProductResolver::InputProductResolver ( std::shared_ptr< BranchDescription const >  bd)
inlineexplicit

Member Function Documentation

bool edm::InputProductResolver::isFromCurrentProcess ( ) const
finalprivatevirtual

Implements edm::DataManagingProductResolver.

Definition at line 238 of file ProductResolvers.cc.

238  {
239  return false;
240  }
void edm::InputProductResolver::prefetchAsync_ ( WaitingTask waitTask,
Principal const &  principal,
bool  skipCurrentProcess,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const
overrideprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 172 of file ProductResolvers.cc.

References edm::ProductResolverBase::branchDescription(), edm::InEvent, edm::ServiceRegistry::instance(), edm::make_functor_task(), edm::ServiceRegistry::presentToken(), cmsRelvalreport::principal(), edm::ProductResolverBase::productResolved(), edm::SerialTaskQueueChain::push(), edm::ProductResolverBase::putProduct(), createBeamHaloJobs::queue, matplotRender::reader, and lumiQTWidget::t.

176  {
177  m_waitingTasks.add(waitTask);
178 
179  bool expected = false;
180  if( m_prefetchRequested.compare_exchange_strong(expected, true) ) {
181 
182  //need to make sure Service system is activated on the reading thread
183  auto token = ServiceRegistry::instance().presentToken();
184  auto workToDo = [this, mcc, &principal, token] () {
185  ServiceRegistry::Operate guard(token);
186  try {
187  resolveProductImpl<true>([this,&principal,mcc]() {
188  if(principal.branchType() != InEvent) { return; }
189  if(auto reader = principal.reader()) {
190  std::unique_lock<std::recursive_mutex> guard;
191  if(auto sr = reader->sharedResources().second) {
192  guard =std::unique_lock<std::recursive_mutex>(*sr);
193  }
194  if ( not productResolved()) {
195  //another thread could have finished this while we were waiting
196  putProduct( reader->getProduct(BranchKey(branchDescription()), &principal, mcc));
197  }
198  }
199  });
200  } catch(...) {
201  this->m_waitingTasks.doneWaiting(std::current_exception());
202  return;
203  }
204  this->m_waitingTasks.doneWaiting(nullptr);
205  };
206 
207  SerialTaskQueueChain* queue = nullptr;
208  if(auto reader = principal.reader()) {
209  if (auto shared_res = reader->sharedResources().first) {
210  queue = &(shared_res->serialQueueChain());
211  }
212  }
213  if(queue) {
214  queue->push(workToDo);
215  } else {
216  //Have to create a new task
217  auto t = make_functor_task(tbb::task::allocate_root(),
218  workToDo);
219  tbb::task::spawn(*t);
220  }
221  }
222  }
FunctorTask< F > * make_functor_task(ALLOC &&iAlloc, F f)
Definition: FunctorTask.h:47
void add(WaitingTask *)
Adds task to the waiting list.
WaitingTaskList m_waitingTasks
ServiceToken presentToken() const
void putProduct(std::unique_ptr< WrapperBase > edp) const
void doneWaiting(std::exception_ptr iPtr)
Signals that the resource is now available and tasks should be spawned.
def principal(options)
static ServiceRegistry & instance()
std::atomic< bool > m_prefetchRequested
BranchDescription const & branchDescription() const
void edm::InputProductResolver::putProduct_ ( std::unique_ptr< WrapperBase edp) const
overrideprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 424 of file ProductResolvers.cc.

References eostools::move(), edm::ProductResolverBase::productResolved(), and edm::DataManagingProductResolver::setProduct().

424  {
425  if ( not productResolved()) {
426  //Another thread could have set this
427  setProduct(std::move(edp));
428  }
429  }
void setProduct(std::unique_ptr< WrapperBase > edp) const
def move(src, dest)
Definition: eostools.py:510
void edm::InputProductResolver::resetProductData_ ( bool  deleteEarly)
overrideprivatevirtual

Reimplemented from edm::DataManagingProductResolver.

Definition at line 225 of file ProductResolvers.cc.

References edm::DataManagingProductResolver::resetProductData_().

225  {
226  m_prefetchRequested = false;
229  }
void resetProductData_(bool deleteEarly) override
WaitingTaskList m_waitingTasks
void reset()
Resets access to the resource so that added tasks will wait.
std::atomic< bool > m_prefetchRequested
ProductResolverBase::Resolution edm::InputProductResolver::resolveProduct_ ( Principal const &  principal,
bool  skipCurrentProcess,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const
overrideprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 114 of file ProductResolvers.cc.

References edm::ProductResolverBase::branchDescription(), revisionDML::branchType(), edm::ModuleCallingContext::getStreamContext(), edm::InEvent, edm::make_sentry(), cmsRelvalreport::principal(), edm::ProductResolverBase::productResolved(), edm::ProductResolverBase::putProduct(), and matplotRender::reader.

117  {
118  return resolveProductImpl<true>([this,&principal,mcc]() {
119  auto branchType = principal.branchType();
120  if(branchType != InEvent) {
121  //delayed get has not been allowed with Run or Lumis
122  // The file may already be closed so the reader is invalid
123  return;
124  }
125  if(mcc and (branchType == InEvent) and aux_) {
126  aux_->preModuleDelayedGetSignal_.emit(*(mcc->getStreamContext()),*mcc);
127  }
128 
129  auto sentry( make_sentry(mcc,
130  [this, branchType](ModuleCallingContext const* iContext){
131  if(branchType == InEvent and aux_) {
132  aux_->postModuleDelayedGetSignal_.emit(*(iContext->getStreamContext()), *iContext); }
133  }));
134 
135  if(auto reader=principal.reader()) {
136  std::unique_lock<std::recursive_mutex> guard;
137  if(auto sr = reader->sharedResources().second) {
138  guard =std::unique_lock<std::recursive_mutex>(*sr);
139  }
140  if ( not productResolved()) {
141  //another thread could have beaten us here
142  putProduct( reader->getProduct(BranchKey(branchDescription()), &principal, mcc));
143  }
144  }
145  });
146 
147  }
std::unique_ptr< T, F > make_sentry(T *iObject, F iFunc)
NOTE: if iObject is null, then iFunc will not be called.
Definition: make_sentry.h:29
UnscheduledAuxiliary const * aux_
void putProduct(std::unique_ptr< WrapperBase > edp) const
def principal(options)
BranchDescription const & branchDescription() const
def branchType(schema, name)
Definition: revisionDML.py:112
void edm::InputProductResolver::retrieveAndMerge_ ( Principal const &  principal) const
overrideprivatevirtual

Reimplemented from edm::ProductResolverBase.

Definition at line 150 of file ProductResolvers.cc.

References edm::ProductResolverBase::branchDescription(), edm::DataManagingProductResolver::defaultStatus(), eostools::move(), edm::ProductResolverBase::putOrMergeProduct(), edm::Principal::reader(), matplotRender::reader, edm::DataManagingProductResolver::setFailedStatus(), and edm::DataManagingProductResolver::status().

150  {
151  if(auto reader = principal.reader()) {
152 
153  std::unique_lock<std::recursive_mutex> guard;
154  if(auto sr = reader->sharedResources().second) {
155  guard =std::unique_lock<std::recursive_mutex>(*sr);
156  }
157 
158  //Can't use resolveProductImpl since it first checks to see
159  // if the product was already retrieved and then returns if it is
160  BranchKey const bk = BranchKey(branchDescription());
161  std::unique_ptr<WrapperBase> edp(reader->getProduct(bk, &principal));
162 
163  if(edp.get() != nullptr) {
165  } else if( status()== defaultStatus()) {
166  setFailedStatus();
167  }
168  }
169  }
ProductStatus status() const
def principal(options)
ProductStatus defaultStatus() const
BranchDescription const & branchDescription() const
void putOrMergeProduct(std::unique_ptr< WrapperBase > edp) const
def move(src, dest)
Definition: eostools.py:510
void edm::InputProductResolver::setupUnscheduled ( UnscheduledConfigurator const &  iConfigure)
finalvirtual

Reimplemented from edm::ProductResolverBase.

Definition at line 232 of file ProductResolvers.cc.

References edm::UnscheduledConfigurator::auxiliary().

232  {
233  aux_ = iConfigure.auxiliary();
234  }
UnscheduledAuxiliary const * aux_
bool edm::InputProductResolver::unscheduledWasNotRun_ ( ) const
inlinefinalprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 122 of file ProductResolvers.h.

References edm::DataManagingProductResolver::resetProductData_().

122 {return false;}

Member Data Documentation

UnscheduledAuxiliary const* edm::InputProductResolver::aux_
private

Definition at line 128 of file ProductResolvers.h.

std::atomic<bool> edm::InputProductResolver::m_prefetchRequested
mutableprivate

Definition at line 126 of file ProductResolvers.h.

WaitingTaskList edm::InputProductResolver::m_waitingTasks
mutableprivate

Definition at line 127 of file ProductResolvers.h.