CMS 3D CMS Logo

ESProductResolver.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_ESProductResolver_h
2 #define FWCore_Framework_ESProductResolver_h
3 // -*- C++ -*-
4 //
5 // Package: Framework
6 // Class : ESProductResolver
7 //
17 //
18 // Author: Chris Jones
19 // Created: Thu Mar 31 12:43:01 EST 2005
20 //
21 
22 // system include files
23 #include <atomic>
24 
25 // user include files
28 
29 // forward declarations
30 namespace edm {
31  class EventSetupImpl;
32  class ServiceToken;
33  class ESParentContext;
34 
35  namespace eventsetup {
36  struct ComponentDescription;
37  class DataKey;
38  class EventSetupRecordImpl;
39 
41  public:
43  ESProductResolver(ESProductResolver const&) = delete;
44  ESProductResolver const& operator=(ESProductResolver const&) = delete;
45  virtual ~ESProductResolver();
46 
47  // ---------- const member functions ---------------------
48  bool cacheIsValid() const { return cacheIsValid_.load(std::memory_order_acquire); }
49 
51  EventSetupRecordImpl const&,
52  DataKey const&,
53  EventSetupImpl const*,
54  ServiceToken const&,
55  ESParentContext const&) const;
56 
57  void const* getAfterPrefetch(const EventSetupRecordImpl& iRecord, const DataKey& iKey, bool iTransiently) const;
58 
61 
62  // ---------- member functions ---------------------------
63  void invalidate() {
66  }
67 
68  void resetIfTransient();
69 
71 
72  virtual void initializeForNewIOV() {}
73 
74  protected:
82  EventSetupRecordImpl const&,
83  DataKey const& iKey,
84  EventSetupImpl const*,
85  ServiceToken const&,
86  ESParentContext const&) = 0;
87 
91  virtual void invalidateCache() = 0;
92 
98  virtual void invalidateTransientCache();
99 
102  virtual void const* getAfterPrefetchImpl() const = 0;
103 
104  void clearCacheIsValid();
105 
106  private:
107  // ---------- member data --------------------------------
109  CMS_THREAD_SAFE mutable void const* cache_; //protected by a global mutex
110  mutable std::atomic<bool> cacheIsValid_;
111 
112  // While implementing the set of code changes that enabled support
113  // for concurrent IOVs, I have gone to some effort to maintain
114  // the same behavior for this variable and the things that depend on
115  // it. My thinking is that we are going to revisit this and make
116  // changes in the not so distant future so that the transient feature
117  // works again. Alternatively, we may go through and delete it and
118  // everything related to it.
119 
120  // First comment is that there is only one context in which the value
121  // in nonTransientAccessRequested_ is used. This is in the resetIfTransient
122  // function. This function is only called immediately after invalidate
123  // was called. Therefore the value is always false and condition in
124  // resetIfTransient always evaluates true. So in the current code this
125  // data member does nothing and has absolutely no purpose. We should
126  // delete it and the associated code if we do not modify the code to
127  // actually make use of the value stored sometime soon.
128 
129  // Currently, this usage occurs is when force cache clear
130  // is called from EventProcessor at beginRun (which only happens
131  // when a certain configuration parameter is set) and propagates down.
132  // It is also used when the looper is trying to start a new loop and
133  // calls resetRecordPlusDependentRecords. It is not currently used in
134  // any other context.
135  //
136  // One other thing to note is that the virtual invalidateTransientCache
137  // function is defined in this class to just call invalidateCache.
138  // Outside of unit tests, the only thing that overrides this definition
139  // is in CondCore/ESSources/interface/ESProductResolver.h. So in all other cases
140  // the behavior is that invalidateCache is called twice sometimes
141  // instead of just once. Possibly it is important that invalidateTransientCache
142  // is called in the CondCore code. I don't know.
143  mutable std::atomic<bool> nonTransientAccessRequested_;
144  };
145  } // namespace eventsetup
146 } // namespace edm
147 #endif
void setProviderDescription(ComponentDescription const *iDesc)
virtual void const * getAfterPrefetchImpl() const =0
std::atomic< bool > nonTransientAccessRequested_
ComponentDescription const * providerDescription() const
returns the description of the ESProductResolverProvider which owns this Resolver ...
virtual void prefetchAsyncImpl(WaitingTaskHolder, EventSetupRecordImpl const &, DataKey const &iKey, EventSetupImpl const *, ServiceToken const &, ESParentContext const &)=0
void prefetchAsync(WaitingTaskHolder, EventSetupRecordImpl const &, DataKey const &, EventSetupImpl const *, ServiceToken const &, ESParentContext const &) const
#define CMS_THREAD_SAFE
ComponentDescription const * description_
void const * getAfterPrefetch(const EventSetupRecordImpl &iRecord, const DataKey &iKey, bool iTransiently) const
ESProductResolver const & operator=(ESProductResolver const &)=delete
HLT enums.