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::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),

◆ 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.

50 { return cacheIsValid_.load(std::memory_order_acquire); }

References cacheIsValid_.

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

◆ clearCacheIsValid()

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

Definition at line 46 of file DataProxy.cc.

46  {
47  nonTransientAccessRequested_.store(false, std::memory_order_release);
48  cache_ = nullptr;
49  cacheIsValid_.store(false, std::memory_order_release);
50  }

References cache_, cacheIsValid_, and nonTransientAccessRequested_.

Referenced by invalidate(), and resetIfTransient().

◆ 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

Definition at line 99 of file DataProxy.cc.

104  {
105  if (!cacheIsValid()) {
107  std::exception_ptr exceptPtr{};
108  iEventSetupImpl->taskArena()->execute([this, &exceptPtr, &iRecord, &iKey, iEventSetupImpl, token, iParent]() {
109  exceptPtr = syncWait([&, this](WaitingTaskHolder&& holder) {
110  prefetchAsync(std::move(holder), iRecord, iKey, iEventSetupImpl, token, iParent);
111  });
112  });
114  cacheIsValid_.store(true, std::memory_order_release);
115  if (exceptPtr) {
116  std::rethrow_exception(exceptPtr);
117  }
118  }
119  return getAfterPrefetch(iRecord, iKey, iTransiently);
120  }

References cache_, cacheIsValid(), cacheIsValid_, getAfterPrefetch(), getAfterPrefetchImpl(), edm::ServiceRegistry::instance(), eostools::move(), prefetchAsync(), edm::ServiceRegistry::presentToken(), edm::syncWait(), edm::EventSetupImpl::taskArena(), and unpackBuffers-CaloStage2::token.

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), submitPVValidationJobs.BetterConfigParser::__updateDict(), rrapi.RRApi::columns(), rrapi.RRApi::count(), rrapi.RRApi::data(), betterConfigParser.BetterConfigParser::getCompares(), edm::eventsetup::EventSetupRecordImpl::getFromProxy(), betterConfigParser.BetterConfigParser::getGeneral(), betterConfigParser.BetterConfigParser::getResultingSection(), submitPVValidationJobs.BetterConfigParser::getResultingSection(), rrapi.RRApi::report(), rrapi.RRApi::reports(), rrapi.RRApi::tables(), rrapi.RRApi::tags(), rrapi.RRApi::templates(), and rrapi.RRApi::workspaces().

◆ 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.

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  }

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

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

◆ getAfterPrefetchImpl()

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

used to retrieve the data from the implementation. The data is then cached locally.

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

Referenced by get(), and getAfterPrefetch().

◆ 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.

71  {
74  }

References clearCacheIsValid(), and invalidateCache().

◆ 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::eventsetup::ESSourceDataProxyBase, and edm::test::TestDataProxy< T >.

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.

59 { invalidateCache(); }

References invalidateCache().

Referenced by resetIfTransient().

◆ 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.

73  {
74  const_cast<DataProxy*>(this)->prefetchAsyncImpl(iTask, iRecord, iKey, iEventSetupImpl, iToken, iParent);
75  }

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

◆ 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::test::TestDataProxy< T >, edm::eventsetup::CallbackProxy< CallbackT, RecordT, DataT >, edm::eventsetup::DataProxyTemplate< RecordT, DataT >, and edm::eventsetup::ESSourceDataProxyBase.

◆ providerDescription()

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

◆ resetIfTransient()

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

Definition at line 52 of file DataProxy.cc.

52  {
53  if (!nonTransientAccessRequested_.load(std::memory_order_acquire)) {
56  }
57  }

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

◆ setProviderDescription()

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

Definition at line 78 of file DataProxy.h.

78 { description_ = iDesc; }

References description_.

Member Data Documentation

◆ cache_

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

Definition at line 117 of file DataProxy.h.

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

◆ cacheIsValid_

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

Definition at line 118 of file DataProxy.h.

Referenced by cacheIsValid(), clearCacheIsValid(), get(), 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().

edm::eventsetup::DataProxy::getAfterPrefetch
void const * getAfterPrefetch(const EventSetupRecordImpl &iRecord, const DataKey &iKey, bool iTransiently) const
Definition: DataProxy.cc:77
edm::eventsetup::DataProxy::cacheIsValid_
std::atomic< bool > cacheIsValid_
Definition: DataProxy.h:118
edm::eventsetup::DataProxy::clearCacheIsValid
void clearCacheIsValid()
Definition: DataProxy.cc:46
edm::eventsetup::dummyDescription
static const ComponentDescription * dummyDescription()
Definition: DataProxy.cc:33
edm::eventsetup::DataProxy::getAfterPrefetchImpl
virtual void const * getAfterPrefetchImpl() const =0
edm::eventsetup::DataProxy::invalidateTransientCache
virtual void invalidateTransientCache()
Definition: DataProxy.cc:59
UNLIKELY
#define UNLIKELY(x)
Definition: Likely.h:21
edm::eventsetup::DataProxy::description_
ComponentDescription const * description_
Definition: DataProxy.h:116
edm::eventsetup::DataProxy::invalidateCache
virtual void invalidateCache()=0
WaitingTaskHolder
edm::eventsetup::DataProxy::cache_
void const * cache_
Definition: DataProxy.h:117
edm::eventsetup::DataProxy::prefetchAsync
void prefetchAsync(WaitingTaskHolder, EventSetupRecordImpl const &, DataKey const &, EventSetupImpl const *, ServiceToken const &, ESParentContext const &) const
Definition: DataProxy.cc:68
edm::ServiceRegistry::presentToken
ServiceToken presentToken() const
Definition: ServiceRegistry.cc:63
edm::eventsetup::DataProxy::cacheIsValid
bool cacheIsValid() const
Definition: DataProxy.h:50
edm::ServiceRegistry::instance
static ServiceRegistry & instance()
Definition: ServiceRegistry.cc:90
eostools.move
def move(src, dest)
Definition: eostools.py:511
LIKELY
#define LIKELY(x)
Definition: Likely.h:20
edm::eventsetup::DataProxy::nonTransientAccessRequested_
std::atomic< bool > nonTransientAccessRequested_
Definition: DataProxy.h:151
edm::syncWait
std::exception_ptr syncWait(F &&iFunc)
Definition: include_first_syncWait.h:17
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316