CMS 3D CMS Logo

ESProductResolver.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Framework
4 // Class : ESProductResolver
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Author: Chris Jones
10 // Created: Thu Mar 31 12:49:19 EST 2005
11 //
12 
18 
19 namespace edm {
20  namespace eventsetup {
21 
23  static const ComponentDescription s_desc;
24  return &s_desc;
25  }
26 
28  : description_(dummyDescription()),
29  cache_(nullptr),
30  cacheIsValid_(false),
31  nonTransientAccessRequested_(false) {}
32 
34 
36  nonTransientAccessRequested_.store(false, std::memory_order_release);
37  cache_ = nullptr;
38  cacheIsValid_.store(false, std::memory_order_release);
39  }
40 
42  if (!nonTransientAccessRequested_.load(std::memory_order_acquire)) {
45  }
46  }
47 
49 
50  namespace {
51  void throwMakeException(const EventSetupRecordImpl& iRecord, const DataKey& iKey) {
52  throw MakeDataException(iRecord.key(), iKey);
53  }
54 
55  } // namespace
56 
58  EventSetupRecordImpl const& iRecord,
59  DataKey const& iKey,
60  EventSetupImpl const* iEventSetupImpl,
61  ServiceToken const& iToken,
62  ESParentContext const& iParent) const {
63  const_cast<ESProductResolver*>(this)->prefetchAsyncImpl(iTask, iRecord, iKey, iEventSetupImpl, iToken, iParent);
64  }
65 
67  const DataKey& iKey,
68  bool iTransiently) const {
69  //We need to set the AccessType for each request so this can't be called in an earlier function in the stack.
70  //This also must be before the cache_ check since we want to setCacheIsValid before a possible
71  // exception throw. If we don't, 'getImpl' will be called again on a second request for the data.
72 
73  if LIKELY (!iTransiently) {
74  nonTransientAccessRequested_.store(true, std::memory_order_release);
75  }
76 
77  if UNLIKELY (!cacheIsValid()) {
79  cacheIsValid_.store(true, std::memory_order_release);
80  }
81 
82  if UNLIKELY (nullptr == cache_) {
83  throwMakeException(iRecord, iKey);
84  }
85  return cache_;
86  }
87 
88  } // namespace eventsetup
89 } // namespace edm
virtual void const * getAfterPrefetchImpl() const =0
std::atomic< bool > nonTransientAccessRequested_
#define LIKELY(x)
Definition: Likely.h:20
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
void const * getAfterPrefetch(const EventSetupRecordImpl &iRecord, const DataKey &iKey, bool iTransiently) const
EventSetupRecordKey const & key() const
HLT enums.
#define UNLIKELY(x)
Definition: Likely.h:21
static const ComponentDescription * dummyDescription()