CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Attributes
edm::eventsetup::DataProxy Class Referenceabstract

#include <DataProxy.h>

Inheritance diagram for edm::eventsetup::DataProxy:
edm::eventsetup::CallbackProxy< CallbackT, RecordT, DataT > edm::eventsetup::DataProxyTemplate< RecordT, DataT > edm::eventsetup::ESSourceDataProxyBase edm::test::TestDataProxy< T > edm::eventsetup::ESSourceDataProxyConcurrentBase edm::eventsetup::ESSourceDataProxyNonConcurrentBase edm::eventsetup::ESSourceConcurrentDataProxyTemplate< DataT > edm::eventsetup::ESSourceDataProxyTemplate< DataT > DataProxy< RecordT, DataT, Initializer >

Public Member Functions

bool cacheIsValid () const
 
 DataProxy ()
 
 DataProxy (DataProxy const &)=delete
 
void const * get (EventSetupRecordImpl const &, DataKey const &, bool iTransiently, ActivityRegistry const *, EventSetupImpl const *, ESParentContext const &) const
 
void const * getAfterPrefetch (const EventSetupRecordImpl &iRecord, const DataKey &iKey, bool iTransiently) const
 
virtual void initializeForNewIOV ()
 
void invalidate ()
 
DataProxy const & operator= (DataProxy const &)=delete
 
void prefetchAsync (WaitingTaskHolder, EventSetupRecordImpl const &, DataKey const &, EventSetupImpl const *, ServiceToken const &, ESParentContext const &) const
 
ComponentDescription const * providerDescription () const
 returns the description of the DataProxyProvider which owns this Proxy More...
 
void resetIfTransient ()
 
void setProviderDescription (ComponentDescription const *iDesc)
 
virtual ~DataProxy ()
 

Protected Member Functions

void clearCacheIsValid ()
 
virtual void const * getAfterPrefetchImpl () const =0
 
virtual void invalidateCache ()=0
 
virtual void invalidateTransientCache ()
 
virtual void prefetchAsyncImpl (WaitingTaskHolder, EventSetupRecordImpl const &, DataKey const &iKey, EventSetupImpl const *, ServiceToken const &, ESParentContext const &)=0
 

Private Attributes

void const * cache_
 
std::atomic< bool > cacheIsValid_
 
ComponentDescription const * description_
 
std::atomic< bool > nonTransientAccessRequested_
 

Detailed Description

Description: Base class for data Proxies held by a EventSetupRecord

Usage: This class defines the interface used to handle retrieving data from an EventSetup Record.

Definition at line 42 of file DataProxy.h.

Constructor & Destructor Documentation

◆ DataProxy() [1/2]

DataProxy< RecordT, DataT, Initializer >::DataProxy ( )

Definition at line 38 of file DataProxy.cc.

40  cache_(nullptr),
41  cacheIsValid_(false),
std::atomic< bool > nonTransientAccessRequested_
Definition: DataProxy.h:151
std::atomic< bool > cacheIsValid_
Definition: DataProxy.h:118
ComponentDescription const * description_
Definition: DataProxy.h:116
static const ComponentDescription * dummyDescription()
Definition: DataProxy.cc:33

◆ DataProxy() [2/2]

edm::eventsetup::DataProxy::DataProxy ( DataProxy const &  )
delete

◆ ~DataProxy()

DataProxy< RecordT, DataT, Initializer >::~DataProxy ( )
virtual

Definition at line 44 of file DataProxy.cc.

44 {}

Member Function Documentation

◆ cacheIsValid()

bool edm::eventsetup::DataProxy::cacheIsValid ( ) const
inline

Definition at line 50 of file DataProxy.h.

References cacheIsValid_.

Referenced by get(), getAfterPrefetch(), and edm::eventsetup::EventSetupRecordImpl::wasGotten().

50 { return cacheIsValid_.load(std::memory_order_acquire); }
std::atomic< bool > cacheIsValid_
Definition: DataProxy.h:118

◆ clearCacheIsValid()

void DataProxy< RecordT, DataT, Initializer >::clearCacheIsValid ( )
protected

Definition at line 46 of file DataProxy.cc.

References cache_, cacheIsValid_, and nonTransientAccessRequested_.

Referenced by invalidate(), and resetIfTransient().

46  {
47  nonTransientAccessRequested_.store(false, std::memory_order_release);
48  cache_ = nullptr;
49  cacheIsValid_.store(false, std::memory_order_release);
50  }
std::atomic< bool > nonTransientAccessRequested_
Definition: DataProxy.h:151
std::atomic< bool > cacheIsValid_
Definition: DataProxy.h:118

◆ get()

const void * DataProxy< RecordT, DataT, Initializer >::get ( EventSetupRecordImpl const &  iRecord,
DataKey const &  iKey,
bool  iTransiently,
ActivityRegistry const *  activityRegistry,
EventSetupImpl const *  iEventSetupImpl,
ESParentContext const &  iParent 
) const

◆ getAfterPrefetch()

void const * DataProxy< RecordT, DataT, Initializer >::getAfterPrefetch ( const EventSetupRecordImpl iRecord,
const DataKey iKey,
bool  iTransiently 
) const

Definition at line 77 of file DataProxy.cc.

References cache_, cacheIsValid(), cacheIsValid_, getAfterPrefetchImpl(), LIKELY, nonTransientAccessRequested_, and UNLIKELY.

Referenced by get(), and edm::eventsetup::EventSetupRecordImpl::getFromProxyAfterPrefetch().

79  {
80  //We need to set the AccessType for each request so this can't be called in an earlier function in the stack.
81  //This also must be before the cache_ check since we want to setCacheIsValid before a possible
82  // exception throw. If we don't, 'getImpl' will be called again on a second request for the data.
83 
84  if LIKELY (!iTransiently) {
85  nonTransientAccessRequested_.store(true, std::memory_order_release);
86  }
87 
88  if UNLIKELY (!cacheIsValid()) {
90  cacheIsValid_.store(true, std::memory_order_release);
91  }
92 
93  if UNLIKELY (nullptr == cache_) {
94  throwMakeException(iRecord, iKey);
95  }
96  return cache_;
97  }
#define LIKELY(x)
Definition: Likely.h:20
std::atomic< bool > nonTransientAccessRequested_
Definition: DataProxy.h:151
std::atomic< bool > cacheIsValid_
Definition: DataProxy.h:118
bool cacheIsValid() const
Definition: DataProxy.h:50
#define UNLIKELY(x)
Definition: Likely.h:21
virtual void const * getAfterPrefetchImpl() const =0

◆ getAfterPrefetchImpl()

virtual void const* edm::eventsetup::DataProxy::getAfterPrefetchImpl ( ) const
protectedpure virtual

◆ initializeForNewIOV()

virtual void edm::eventsetup::DataProxy::initializeForNewIOV ( )
inlinevirtual

Reimplemented in DataProxy< RecordT, DataT, Initializer >.

Definition at line 80 of file DataProxy.h.

80 {}

◆ invalidate()

void edm::eventsetup::DataProxy::invalidate ( )
inline

Definition at line 71 of file DataProxy.h.

References clearCacheIsValid(), and invalidateCache().

71  {
74  }
virtual void invalidateCache()=0

◆ invalidateCache()

virtual void edm::eventsetup::DataProxy::invalidateCache ( )
protectedpure virtual

indicates that the Proxy should invalidate any cached information as that information has 'expired' (i.e. we have moved to a new IOV)

Implemented in edm::eventsetup::DataProxyTemplate< RecordT, DataT >, edm::eventsetup::CallbackProxy< CallbackT, RecordT, DataT >, edm::test::TestDataProxy< T >, and edm::eventsetup::ESSourceDataProxyBase.

Referenced by invalidate(), and invalidateTransientCache().

◆ invalidateTransientCache()

void DataProxy< RecordT, DataT, Initializer >::invalidateTransientCache ( )
protectedvirtual

indicates that the Proxy should invalidate any cached information as that information was accessed transiently and therefore is not intended to be kept over the entire IOV. Default is to call invalidateCache().

Reimplemented in edm::eventsetup::ESSourceDataProxyBase.

Definition at line 59 of file DataProxy.cc.

References invalidateCache().

Referenced by resetIfTransient().

59 { invalidateCache(); }
virtual void invalidateCache()=0

◆ operator=()

DataProxy const& edm::eventsetup::DataProxy::operator= ( DataProxy const &  )
delete

◆ prefetchAsync()

void DataProxy< RecordT, DataT, Initializer >::prefetchAsync ( WaitingTaskHolder  iTask,
EventSetupRecordImpl const &  iRecord,
DataKey const &  iKey,
EventSetupImpl const *  iEventSetupImpl,
ServiceToken const &  iToken,
ESParentContext const &  iParent 
) const

Definition at line 68 of file DataProxy.cc.

References prefetchAsyncImpl().

Referenced by edm::eventsetup::EventSetupRecordImpl::prefetchAsync().

73  {
74  const_cast<DataProxy*>(this)->prefetchAsyncImpl(iTask, iRecord, iKey, iEventSetupImpl, iToken, iParent);
75  }
virtual void prefetchAsyncImpl(WaitingTaskHolder, EventSetupRecordImpl const &, DataKey const &iKey, EventSetupImpl const *, ServiceToken const &, ESParentContext const &)=0

◆ prefetchAsyncImpl()

virtual void edm::eventsetup::DataProxy::prefetchAsyncImpl ( WaitingTaskHolder  ,
EventSetupRecordImpl const &  ,
DataKey const &  iKey,
EventSetupImpl const *  ,
ServiceToken const &  ,
ESParentContext const &   
)
protectedpure virtual

This is the function which does the real work of getting the data if it is not already cached. The returning 'void const*' must point to an instance of the class type corresponding to the type designated in iKey. So if iKey refers to a base class interface the pointer must be a pointer to that base class interface and not a pointer to an inheriting class instance.

Implemented in edm::eventsetup::DataProxyTemplate< RecordT, DataT >, edm::eventsetup::CallbackProxy< CallbackT, RecordT, DataT >, edm::eventsetup::ESSourceDataProxyNonConcurrentBase, edm::test::TestDataProxy< T >, and edm::eventsetup::ESSourceDataProxyConcurrentBase.

Referenced by prefetchAsync().

◆ providerDescription()

ComponentDescription const* edm::eventsetup::DataProxy::providerDescription ( ) const
inline

◆ resetIfTransient()

void DataProxy< RecordT, DataT, Initializer >::resetIfTransient ( )

Definition at line 52 of file DataProxy.cc.

References clearCacheIsValid(), invalidateTransientCache(), and nonTransientAccessRequested_.

52  {
53  if (!nonTransientAccessRequested_.load(std::memory_order_acquire)) {
56  }
57  }
virtual void invalidateTransientCache()
Definition: DataProxy.cc:59
std::atomic< bool > nonTransientAccessRequested_
Definition: DataProxy.h:151

◆ setProviderDescription()

void edm::eventsetup::DataProxy::setProviderDescription ( ComponentDescription const *  iDesc)
inline

Definition at line 78 of file DataProxy.h.

References description_.

78 { description_ = iDesc; }
ComponentDescription const * description_
Definition: DataProxy.h:116

Member Data Documentation

◆ cache_

void const* edm::eventsetup::DataProxy::cache_
mutableprivate

Definition at line 117 of file DataProxy.h.

Referenced by clearCacheIsValid(), and getAfterPrefetch().

◆ cacheIsValid_

std::atomic<bool> edm::eventsetup::DataProxy::cacheIsValid_
mutableprivate

Definition at line 118 of file DataProxy.h.

Referenced by cacheIsValid(), clearCacheIsValid(), and getAfterPrefetch().

◆ description_

ComponentDescription const* edm::eventsetup::DataProxy::description_
private

Definition at line 116 of file DataProxy.h.

Referenced by providerDescription(), and setProviderDescription().

◆ nonTransientAccessRequested_

std::atomic<bool> edm::eventsetup::DataProxy::nonTransientAccessRequested_
mutableprivate

Definition at line 151 of file DataProxy.h.

Referenced by clearCacheIsValid(), getAfterPrefetch(), and resetIfTransient().