CMS 3D CMS Logo

ESSourceProductResolverBase.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_ESSourceProductResolverBase_h
2 #define FWCore_Framework_ESSourceProductResolverBase_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Framework
6 // Class : ESSourceProductResolverBase
7 //
19 //
20 // Original Author: Chris Jones
21 // Created: 14/05/2020
22 //
23 
24 // system include files
25 #include <atomic>
26 
27 // user include files
32 
33 // forward declarations
34 
35 namespace edm::eventsetup {
37  public:
39 
40  protected:
41  void invalidateCache() override {
43  m_prefetching = false;
44  }
45  void invalidateTransientCache() override {}
46 
47  virtual void prefetch(edm::eventsetup::DataKey const& iKey, EventSetupRecordDetails) = 0;
48 
49  //Should call from prefetchAsyncImpl
50  template <typename ASYNC, typename GUARD>
51  void prefetchAsyncImplTemplate(ASYNC iAsync,
52  GUARD iGuardFactory,
55  edm::eventsetup::DataKey const& iKey,
56  edm::ESParentContext const& iContext) noexcept {
57  auto group = iTask.group();
58  if (needToPrefetch(std::move(iTask))) {
59  iAsync(*group, [this, iGuardFactory, &iRecord, iKey, iContext]() {
60  try {
61  guardPrefetch(iGuardFactory, iRecord, iKey, iContext);
62  m_waitingList.doneWaiting(std::exception_ptr{});
63  } catch (...) {
64  m_waitingList.doneWaiting(std::current_exception());
65  }
66  });
67  }
68  }
69 
70  private:
71  template <typename GUARD>
72  void guardPrefetch(GUARD iGuardFactory,
74  edm::eventsetup::DataKey const& iKey,
75  edm::ESParentContext const& iContext) {
76  [[maybe_unused]] auto guard = iGuardFactory();
77  doPrefetchAndSignals(iES, iKey, iContext);
78  }
79 
80  bool needToPrefetch(edm::WaitingTaskHolder iTask) noexcept;
81 
83  edm::eventsetup::DataKey const& iKey,
84  edm::ESParentContext const&);
85 
86  // ---------- member data --------------------------------
87 
89  std::atomic<bool> m_prefetching;
90  };
91 } // namespace edm::eventsetup
92 #endif
void doPrefetchAndSignals(edm::eventsetup::EventSetupRecordImpl const &, edm::eventsetup::DataKey const &iKey, edm::ESParentContext const &)
void reset()
Resets access to the resource so that added tasks will wait.
void doneWaiting(std::exception_ptr iPtr)
Signals that the resource is now available and tasks should be spawned.
bool needToPrefetch(edm::WaitingTaskHolder iTask) noexcept
virtual void prefetch(edm::eventsetup::DataKey const &iKey, EventSetupRecordDetails)=0
void guardPrefetch(GUARD iGuardFactory, edm::eventsetup::EventSetupRecordImpl const &iES, edm::eventsetup::DataKey const &iKey, edm::ESParentContext const &iContext)
void prefetchAsyncImplTemplate(ASYNC iAsync, GUARD iGuardFactory, edm::WaitingTaskHolder iTask, edm::eventsetup::EventSetupRecordImpl const &iRecord, edm::eventsetup::DataKey const &iKey, edm::ESParentContext const &iContext) noexcept
def move(src, dest)
Definition: eostools.py:511