CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator > Class Template Reference

#include <Callback.h>

Public Types

using method_type = TReturn(T ::*)(const TRecord &)
 

Public Member Functions

 Callback (const Callback &)=delete
 
 Callback (T *iProd, method_type iMethod, unsigned int iID, const TDecorator &iDec=TDecorator())
 
Callbackclone ()
 
ESProxyIndex const * getTokenIndices () const
 
template<class DataT >
void holdOntoPointer (DataT *iData)
 
void newRecordComing ()
 
const Callbackoperator= (const Callback &)=delete
 
void prefetchAsync (WaitingTaskHolder iTask, EventSetupRecordImpl const *iRecord, EventSetupImpl const *iEventSetupImpl, ServiceToken const &token, ESParentContext const &iParent)
 
template<class RemainingContainerT , class DataT , class ProductsT >
void setData (ProductsT &iProducts)
 
void storeReturnedValues (TReturn iReturn)
 
unsigned int transitionID () const
 

Private Member Functions

bool handleMayGet (EventSetupRecordImpl const *iRecord, EventSetupImpl const *iEventSetupImpl)
 
void prefetchNeededDataAsync (WaitingTaskHolder task, EventSetupImpl const *iImpl, ESProxyIndex const *proxies, edm::ServiceToken const &token) const
 
void runProducerAsync (tbb::task_group *iGroup, std::exception_ptr const *iExcept, EventSetupRecordImpl const *iRecord, EventSetupImpl const *iEventSetupImpl, ServiceToken const &token)
 

Private Attributes

ESModuleCallingContext callingContext_
 
TDecorator decorator_
 
const unsigned int id_
 
method_type method_
 
std::optional< std::vector< ESProxyIndex > > postMayGetProxies_
 
edm::propagate_const< T * > producer_
 
std::array< void *, produce::size< TReturn >::value > proxyData_
 
edm::WaitingTaskList taskList_
 
std::atomic< bool > wasCalledForThisRecord_
 

Detailed Description

template<typename T, typename TReturn, typename TRecord, typename TDecorator = CallbackSimpleDecorator<TRecord>>
class edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >

Description: Functional object used as the 'callback' for the CallbackProxy

Usage: <usage>

Definition at line 54 of file Callback.h.

Member Typedef Documentation

◆ method_type

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
using edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::method_type = TReturn (T ::*)(const TRecord&)

Definition at line 56 of file Callback.h.

Constructor & Destructor Documentation

◆ Callback() [1/2]

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::Callback ( T iProd,
method_type  iMethod,
unsigned int  iID,
const TDecorator &  iDec = TDecorator() 
)
inline

Definition at line 58 of file Callback.h.

59  : proxyData_{},
60  producer_(iProd),
61  callingContext_(&iProd->description()),
62  method_(iMethod),
63  id_(iID),
65  decorator_(iDec) {}

Referenced by edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::clone().

◆ Callback() [2/2]

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::Callback ( const Callback< T, TReturn, TRecord, TDecorator > &  )
delete

Member Function Documentation

◆ clone()

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
Callback* edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::clone ( void  )
inline

◆ getTokenIndices()

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
ESProxyIndex const* edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::getTokenIndices ( ) const
inline

◆ handleMayGet()

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
bool edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::handleMayGet ( EventSetupRecordImpl const *  iRecord,
EventSetupImpl const *  iEventSetupImpl 
)
inlineprivate

◆ holdOntoPointer()

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
template<class DataT >
void edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::holdOntoPointer ( DataT *  iData)
inline

◆ newRecordComing()

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
void edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::newRecordComing ( )
inline

◆ operator=()

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
const Callback& edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::operator= ( const Callback< T, TReturn, TRecord, TDecorator > &  )
delete

◆ prefetchAsync()

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
void edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::prefetchAsync ( WaitingTaskHolder  iTask,
EventSetupRecordImpl const *  iRecord,
EventSetupImpl const *  iEventSetupImpl,
ServiceToken const &  token,
ESParentContext const &  iParent 
)
inline

Definition at line 72 of file Callback.h.

76  {
77  bool expected = false;
78  auto doPrefetch = wasCalledForThisRecord_.compare_exchange_strong(expected, true);
79  taskList_.add(iTask);
80  auto group = iTask.group();
81  if (doPrefetch) {
83  iRecord->activityRegistry()->preESModulePrefetchingSignal_.emit(iRecord->key(), callingContext_);
84  if UNLIKELY (producer_->hasMayConsumes()) {
85  //after prefetching need to do the mayGet
86  ServiceWeakToken weakToken = token;
87  auto mayGetTask = edm::make_waiting_task(
88  [this, iRecord, iEventSetupImpl, weakToken, group](std::exception_ptr const* iExcept) {
89  if (iExcept) {
90  runProducerAsync(group, iExcept, iRecord, iEventSetupImpl, weakToken.lock());
91  return;
92  }
93  if (handleMayGet(iRecord, iEventSetupImpl)) {
94  auto runTask = edm::make_waiting_task(
95  [this, group, iRecord, iEventSetupImpl, weakToken](std::exception_ptr const* iExcept) {
96  runProducerAsync(group, iExcept, iRecord, iEventSetupImpl, weakToken.lock());
97  });
99  iEventSetupImpl,
100  &((*postMayGetProxies_).front()),
101  weakToken.lock());
102  } else {
103  runProducerAsync(group, iExcept, iRecord, iEventSetupImpl, weakToken.lock());
104  }
105  });
106 
107  //Get everything we can before knowing about the mayGets
108  prefetchNeededDataAsync(WaitingTaskHolder(*group, mayGetTask), iEventSetupImpl, getTokenIndices(), token);
109  } else {
110  ServiceWeakToken weakToken = token;
112  [this, group, iRecord, iEventSetupImpl, weakToken](std::exception_ptr const* iExcept) {
113  runProducerAsync(group, iExcept, iRecord, iEventSetupImpl, weakToken.lock());
114  });
116  }
117  }
118  }

References edm::eventsetup::EventSetupRecordImpl::activityRegistry(), edm::WaitingTaskList::add(), edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::callingContext_, edm::signalslot::Signal< T >::emit(), edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::getTokenIndices(), edm::WaitingTaskHolder::group(), watchdog::group, edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::handleMayGet(), edm::eventsetup::EventSetupRecordImpl::key(), edm::ESModuleCallingContext::kPrefetching, edm::ServiceWeakToken::lock(), edm::make_waiting_task(), edm::ActivityRegistry::preESModulePrefetchingSignal_, edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::prefetchNeededDataAsync(), edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::producer_, edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::runProducerAsync(), edm::ESModuleCallingContext::setContext(), TrackValidation_cff::task, edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::taskList_, unpackBuffers-CaloStage2::token, UNLIKELY, and edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::wasCalledForThisRecord_.

◆ prefetchNeededDataAsync()

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
void edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::prefetchNeededDataAsync ( WaitingTaskHolder  task,
EventSetupImpl const *  iImpl,
ESProxyIndex const *  proxies,
edm::ServiceToken const &  token 
) const
inlineprivate

◆ runProducerAsync()

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
void edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::runProducerAsync ( tbb::task_group *  iGroup,
std::exception_ptr const *  iExcept,
EventSetupRecordImpl const *  iRecord,
EventSetupImpl const *  iEventSetupImpl,
ServiceToken const &  token 
)
inlineprivate

Definition at line 172 of file Callback.h.

176  {
177  if (iExcept) {
178  //The cache held by the CallbackProxy was already set to invalid at the beginning of the IOV
179  taskList_.doneWaiting(*iExcept);
180  return;
181  }
182  iRecord->activityRegistry()->postESModulePrefetchingSignal_.emit(iRecord->key(), callingContext_);
183  ServiceWeakToken weakToken = token;
184  producer_->queue().push(*iGroup, [this, iRecord, iEventSetupImpl, weakToken]() {
186  std::exception_ptr exceptPtr;
187  try {
188  convertException::wrap([this, iRecord, iEventSetupImpl, weakToken] {
189  auto proxies = getTokenIndices();
190  if (postMayGetProxies_) {
191  proxies = &((*postMayGetProxies_).front());
192  }
193  TRecord rec;
195  rec.setImpl(iRecord, transitionID(), proxies, iEventSetupImpl, &pc, true);
196  ServiceRegistry::Operate operate(weakToken.lock());
197  iRecord->activityRegistry()->preESModuleSignal_.emit(iRecord->key(), callingContext_);
198  struct EndGuard {
199  EndGuard(EventSetupRecordImpl const* iRecord, ESModuleCallingContext const& iContext)
200  : record_{iRecord}, context_{iContext} {}
201  ~EndGuard() { record_->activityRegistry()->postESModuleSignal_.emit(record_->key(), context_); }
202  EventSetupRecordImpl const* record_;
203  ESModuleCallingContext const& context_;
204  };
205  EndGuard guard(iRecord, callingContext_);
206  decorator_.pre(rec);
208  decorator_.post(rec);
209  });
210  } catch (cms::Exception& iException) {
211  auto const& description = producer_->description();
212  std::ostringstream ost;
213  ost << "Running EventSetup component " << description.type_ << "/'" << description.label_;
214  iException.addContext(ost.str());
215  exceptPtr = std::current_exception();
216  }
217  taskList_.doneWaiting(exceptPtr);
218  });
219  }

References edm::eventsetup::EventSetupRecordImpl::activityRegistry(), cms::Exception::addContext(), edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::callingContext_, edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::decorator_, edmLumisInFiles::description, edm::WaitingTaskList::doneWaiting(), edm::signalslot::Signal< T >::emit(), edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::getTokenIndices(), edm::eventsetup::EventSetupRecordImpl::key(), edm::ESModuleCallingContext::kRunning, edm::ServiceWeakToken::lock(), edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::method_, edm::ActivityRegistry::postESModulePrefetchingSignal_, edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::postMayGetProxies_, edm::ActivityRegistry::preESModuleSignal_, edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::producer_, edm::ESModuleCallingContext::setState(), edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::storeReturnedValues(), edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::taskList_, unpackBuffers-CaloStage2::token, edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::transitionID(), and edm::convertException::wrap().

Referenced by edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::prefetchAsync().

◆ setData()

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
template<class RemainingContainerT , class DataT , class ProductsT >
void edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::setData ( ProductsT &  iProducts)
inline

Definition at line 131 of file Callback.h.

131  {
132  DataT* temp = reinterpret_cast<DataT*>(proxyData_[produce::find_index<TReturn, DataT>::value]);
133  if (nullptr != temp) {
134  moveFromTo(iProducts, *temp);
135  }
136  if constexpr (not std::is_same_v<produce::Null, RemainingContainerT>) {
137  setData<typename RemainingContainerT::head_type, typename RemainingContainerT::tail_type>(iProducts);
138  }
139  }

References edm::eventsetup::moveFromTo(), edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::proxyData_, and groupFilesInBlocks::temp.

◆ storeReturnedValues()

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
void edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::storeReturnedValues ( TReturn  iReturn)
inline

Definition at line 125 of file Callback.h.

125  {
127  setData<typename type::head_type, typename type::tail_type>(iReturn);
128  }

Referenced by edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::runProducerAsync().

◆ transitionID()

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
unsigned int edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::transitionID ( ) const
inline

Member Data Documentation

◆ callingContext_

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
ESModuleCallingContext edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::callingContext_
private

◆ decorator_

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
TDecorator edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::decorator_
private

◆ id_

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
const unsigned int edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::id_
private

◆ method_

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
method_type edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::method_
private

◆ postMayGetProxies_

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
std::optional<std::vector<ESProxyIndex> > edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::postMayGetProxies_
private

◆ producer_

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
edm::propagate_const<T*> edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::producer_
private

◆ proxyData_

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
std::array<void*, produce::size<TReturn>::value> edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::proxyData_
private

◆ taskList_

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
edm::WaitingTaskList edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::taskList_
private

◆ wasCalledForThisRecord_

template<typename T , typename TReturn , typename TRecord , typename TDecorator = CallbackSimpleDecorator<TRecord>>
std::atomic<bool> edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::wasCalledForThisRecord_
private
edm::eventsetup::Callback::callingContext_
ESModuleCallingContext callingContext_
Definition: Callback.h:224
edm::eventsetup::produce::product_traits::type
T type
Definition: produce_helpers.h:58
edm::eventsetup::Callback::storeReturnedValues
void storeReturnedValues(TReturn iReturn)
Definition: Callback.h:125
mps_fire.i
i
Definition: mps_fire.py:428
edm::eventsetup::Callback::producer_
edm::propagate_const< T * > producer_
Definition: Callback.h:223
edm::eventsetup::Callback::prefetchNeededDataAsync
void prefetchNeededDataAsync(WaitingTaskHolder task, EventSetupImpl const *iImpl, ESProxyIndex const *proxies, edm::ServiceToken const &token) const
Definition: Callback.h:149
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
cms::Exception::addContext
void addContext(std::string const &context)
Definition: Exception.cc:165
edm::eventsetup::Callback::id_
const unsigned int id_
Definition: Callback.h:228
edmLumisInFiles.description
description
Definition: edmLumisInFiles.py:11
edm::eventsetup::Callback::handleMayGet
bool handleMayGet(EventSetupRecordImpl const *iRecord, EventSetupImpl const *iEventSetupImpl)
Definition: Callback.h:163
edm::propagate_const::get
constexpr element_type const * get() const
Definition: propagate_const.h:64
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
edm::eventsetup::Callback::transitionID
unsigned int transitionID() const
Definition: Callback.h:145
edm::WaitingTaskList::reset
void reset()
Resets access to the resource so that added tasks will wait.
Definition: WaitingTaskList.cc:53
edm::eventsetup::Callback::decorator_
TDecorator decorator_
Definition: Callback.h:230
UNLIKELY
#define UNLIKELY(x)
Definition: Likely.h:21
edm::eventsetup::Callback::proxyData_
std::array< void *, produce::size< TReturn >::value > proxyData_
Definition: Callback.h:221
edm::convertException::wrap
auto wrap(F iFunc) -> decltype(iFunc())
Definition: ConvertException.h:19
edm::ESModuleCallingContext::State::kPrefetching
TrackValidation_cff.task
task
Definition: TrackValidation_cff.py:253
edm::WaitingTaskList::doneWaiting
void doneWaiting(std::exception_ptr iPtr)
Signals that the resource is now available and tasks should be spawned.
Definition: WaitingTaskList.cc:212
WaitingTaskHolder
edm::eventsetup::Callback::Callback
Callback(T *iProd, method_type iMethod, unsigned int iID, const TDecorator &iDec=TDecorator())
Definition: Callback.h:58
edm::eventsetup::Callback::getTokenIndices
ESProxyIndex const * getTokenIndices() const
Definition: Callback.h:146
edm::eventsetup::Callback::taskList_
edm::WaitingTaskList taskList_
Definition: Callback.h:225
edm::ServiceRegistry::Operate
friend class Operate
Definition: ServiceRegistry.h:54
edm::eventsetup::Callback::wasCalledForThisRecord_
std::atomic< bool > wasCalledForThisRecord_
Definition: Callback.h:229
edm::make_waiting_task
FunctorWaitingTask< F > * make_waiting_task(F f)
Definition: WaitingTask.h:101
type
type
Definition: SiPixelVCal_PayloadInspector.cc:39
edm::eventsetup::Callback::runProducerAsync
void runProducerAsync(tbb::task_group *iGroup, std::exception_ptr const *iExcept, EventSetupRecordImpl const *iRecord, EventSetupImpl const *iEventSetupImpl, ServiceToken const &token)
Definition: Callback.h:172
edm::eventsetup::Callback::postMayGetProxies_
std::optional< std::vector< ESProxyIndex > > postMayGetProxies_
Definition: Callback.h:222
edm::ESParentContext
Definition: ESParentContext.h:21
edm::ESModuleCallingContext::setContext
void setContext(State state, ESParentContext const &parent)
Definition: ESModuleCallingContext.cc:18
edm::WaitingTaskList::add
void add(tbb::task_group *, WaitingTask *)
Adds task to the waiting list.
Definition: WaitingTaskList.cc:125
edm::ESModuleCallingContext::setState
void setState(State state)
Definition: ESModuleCallingContext.h:45
edm::eventsetup::produce::find_index::value
constexpr static int value
Definition: produce_helpers.h:128
edm::eventsetup::Callback::method_
method_type method_
Definition: Callback.h:226
edm::ESModuleCallingContext::State::kRunning
cms::Exception
Definition: Exception.h:70
edm::eventsetup::moveFromTo
void moveFromTo(FromT &iFrom, ToT &iTo)
Definition: produce_helpers.h:33
watchdog.group
group
Definition: watchdog.py:82
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316