CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
edm::eventsetup::ESSourceDataProxyBase Class Referenceabstract

#include <ESSourceDataProxyBase.h>

Inheritance diagram for edm::eventsetup::ESSourceDataProxyBase:
edm::eventsetup::DataProxy edm::eventsetup::ESSourceDataProxyTemplate< DataT > DataProxy< RecordT, DataT, Initializer >

Public Member Functions

 ESSourceDataProxyBase (edm::SerialTaskQueue *iQueue, std::mutex *iMutex)
 
std::mutex * mutex () const
 
edm::SerialTaskQueuequeue () const
 
- Public Member Functions inherited from edm::eventsetup::DataProxy
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 invalidateCache () override
 
void invalidateTransientCache () override
 
virtual void prefetch (edm::eventsetup::DataKey const &iKey, EventSetupRecordDetails)=0
 
- Protected Member Functions inherited from edm::eventsetup::DataProxy
void clearCacheIsValid ()
 
virtual void const * getAfterPrefetchImpl () const =0
 

Private Member Functions

void prefetchAsyncImpl (edm::WaitingTaskHolder iTask, edm::eventsetup::EventSetupRecordImpl const &, edm::eventsetup::DataKey const &iKey, edm::EventSetupImpl const *, edm::ServiceToken const &, edm::ESParentContext const &) final
 

Private Attributes

std::mutexm_mutex
 
std::atomic< bool > m_prefetching
 
edm::SerialTaskQueuem_queue
 
edm::WaitingTaskList m_waitingList
 

Detailed Description

Definition at line 39 of file ESSourceDataProxyBase.h.

Constructor & Destructor Documentation

edm::eventsetup::ESSourceDataProxyBase::ESSourceDataProxyBase ( edm::SerialTaskQueue iQueue,
std::mutex iMutex 
)
inline

Definition at line 41 of file ESSourceDataProxyBase.h.

Member Function Documentation

void edm::eventsetup::ESSourceDataProxyBase::invalidateCache ( )
inlineoverrideprotectedvirtual

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

Implements edm::eventsetup::DataProxy.

Definition at line 48 of file ESSourceDataProxyBase.h.

References m_prefetching, m_waitingList, and edm::WaitingTaskList::reset().

48  {
50  m_prefetching = false;
51  }
void reset()
Resets access to the resource so that added tasks will wait.
void edm::eventsetup::ESSourceDataProxyBase::invalidateTransientCache ( )
inlineoverrideprotectedvirtual

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 from edm::eventsetup::DataProxy.

Definition at line 52 of file ESSourceDataProxyBase.h.

52 {}
std::mutex* edm::eventsetup::ESSourceDataProxyBase::mutex ( ) const
inline

Definition at line 45 of file ESSourceDataProxyBase.h.

References m_mutex.

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

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.

Implements edm::eventsetup::DataProxy.

Definition at line 25 of file ESSourceDataProxyBase.cc.

References edm::WaitingTaskList::add(), visDQMUpload::context, edm::WaitingTaskList::doneWaiting(), edm::WaitingTaskHolder::group(), edm::ESModuleCallingContext::kRunning, m_mutex, m_prefetching, m_queue, m_waitingList, prefetch(), edm::eventsetup::DataProxy::providerDescription(), and edm::SerialTaskQueue::push().

30  {
31  bool expected = false;
32  auto doPrefetch = m_prefetching.compare_exchange_strong(expected, true);
33  m_waitingList.add(iTask);
34  if (doPrefetch) {
35  m_queue->push(*iTask.group(), [this, iKey, &iRecord, iParent]() {
36  try {
37  {
38  std::lock_guard<std::mutex> guard(*m_mutex);
40  iRecord.activityRegistry()->preESModuleSignal_.emit(iRecord.key(), context);
41  struct EndGuard {
42  EndGuard(EventSetupRecordImpl const& iRecord, ESModuleCallingContext const& iContext)
43  : record_{iRecord}, context_{iContext} {}
44  ~EndGuard() { record_.activityRegistry()->postESModuleSignal_.emit(record_.key(), context_); }
45  EventSetupRecordImpl const& record_;
46  ESModuleCallingContext const& context_;
47  } guardAR(iRecord, context);
48  prefetch(iKey, EventSetupRecordDetails(&iRecord));
49  }
50  m_waitingList.doneWaiting(std::exception_ptr{});
51  } catch (...) {
52  m_waitingList.doneWaiting(std::current_exception());
53  }
54  });
55  }
56 }
void doneWaiting(std::exception_ptr iPtr)
Signals that the resource is now available and tasks should be spawned.
void push(tbb::task_group &, const T &iAction)
asynchronously pushes functor iAction into queue
void add(tbb::task_group *, WaitingTask *)
Adds task to the waiting list.
ComponentDescription const * providerDescription() const
returns the description of the DataProxyProvider which owns this Proxy
Definition: DataProxy.h:68
virtual void prefetch(edm::eventsetup::DataKey const &iKey, EventSetupRecordDetails)=0
edm::SerialTaskQueue* edm::eventsetup::ESSourceDataProxyBase::queue ( ) const
inline

Definition at line 44 of file ESSourceDataProxyBase.h.

References m_queue.

44 { return m_queue; }

Member Data Documentation

std::mutex* edm::eventsetup::ESSourceDataProxyBase::m_mutex
private

Definition at line 68 of file ESSourceDataProxyBase.h.

Referenced by mutex(), and prefetchAsyncImpl().

std::atomic<bool> edm::eventsetup::ESSourceDataProxyBase::m_prefetching
private

Definition at line 69 of file ESSourceDataProxyBase.h.

Referenced by invalidateCache(), and prefetchAsyncImpl().

edm::SerialTaskQueue* edm::eventsetup::ESSourceDataProxyBase::m_queue
private

Definition at line 67 of file ESSourceDataProxyBase.h.

Referenced by prefetchAsyncImpl(), and queue().

edm::WaitingTaskList edm::eventsetup::ESSourceDataProxyBase::m_waitingList
private

Definition at line 66 of file ESSourceDataProxyBase.h.

Referenced by invalidateCache(), and prefetchAsyncImpl().