CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ESSourceDataProxyBase.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_ESSourceDataProxyBase_h
2 #define FWCore_Framework_ESSourceDataProxyBase_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Framework
6 // Class : ESSourceDataProxyBase
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
31 
32 // forward declarations
33 
34 namespace edm::eventsetup {
36  public:
38 
39  protected:
40  void invalidateCache() override {
42  m_prefetching = false;
43  }
44  void invalidateTransientCache() override {}
45 
46  virtual void prefetch(edm::eventsetup::DataKey const& iKey, EventSetupRecordDetails) = 0;
47 
48  //Should call from prefetchAsyncImpl
49  template <typename ASYNC, typename GUARD>
50  void prefetchAsyncImplTemplate(ASYNC iAsync,
51  GUARD iGuardFactory,
54  edm::eventsetup::DataKey const& iKey,
55  edm::ESParentContext const& iContext) {
56  auto group = iTask.group();
57  if (needToPrefetch(std::move(iTask))) {
58  iAsync(*group, [this, iGuardFactory, &iRecord, iKey, iContext]() {
59  try {
60  guardPrefetch(iGuardFactory, iRecord, iKey, iContext);
61  m_waitingList.doneWaiting(std::exception_ptr{});
62  } catch (...) {
63  m_waitingList.doneWaiting(std::current_exception());
64  }
65  });
66  }
67  }
68 
69  private:
70  template <typename GUARD>
71  void guardPrefetch(GUARD iGuardFactory,
73  edm::eventsetup::DataKey const& iKey,
74  edm::ESParentContext const& iContext) {
75  [[maybe_unused]] auto guard = iGuardFactory();
76  doPrefetchAndSignals(iES, iKey, iContext);
77  }
78 
80 
82  edm::eventsetup::DataKey const& iKey,
83  edm::ESParentContext const&);
84 
85  // ---------- member data --------------------------------
86 
88  std::atomic<bool> m_prefetching;
89  };
90 } // namespace edm::eventsetup
91 #endif
void prefetchAsyncImplTemplate(ASYNC iAsync, GUARD iGuardFactory, edm::WaitingTaskHolder iTask, edm::eventsetup::EventSetupRecordImpl const &iRecord, edm::eventsetup::DataKey const &iKey, edm::ESParentContext const &iContext)
void reset()
Resets access to the resource so that added tasks will wait.
oneapi::tbb::task_group * group() const noexcept
void doneWaiting(std::exception_ptr iPtr)
Signals that the resource is now available and tasks should be spawned.
def move
Definition: eostools.py:511
void doPrefetchAndSignals(edm::eventsetup::EventSetupRecordImpl const &, edm::eventsetup::DataKey const &iKey, edm::ESParentContext const &)
tuple group
Definition: watchdog.py:82
bool needToPrefetch(edm::WaitingTaskHolder iTask)
void guardPrefetch(GUARD iGuardFactory, edm::eventsetup::EventSetupRecordImpl const &iES, edm::eventsetup::DataKey const &iKey, edm::ESParentContext const &iContext)
virtual void prefetch(edm::eventsetup::DataKey const &iKey, EventSetupRecordDetails)=0