2 #ifndef FWCore_Framework_CallbackBase_h 3 #define FWCore_Framework_CallbackBase_h 26 #include <type_traits> 30 #include "oneapi/tbb/task_group.h" 54 namespace eventsetup {
57 template <
typename TRecord>
59 void pre(
const TRecord&) {}
60 void post(
const TRecord&) {}
64 typename TProduceFunc,
70 CallbackBase(
T* iProd, std::shared_ptr<TProduceFunc> iProduceFunc,
unsigned int iID,
const TDecorator& iDec)
88 bool emitPostPrefetchingSignal) {
92 std::exception_ptr
const* iException) {
93 std::exception_ptr excptr;
97 if (emitPostPrefetchingSignal) {
106 excptr = std::current_exception();
117 std::exception_ptr exceptPtr;
123 proxies = &((*postMayGetProxies_).front());
132 : record_{iRecord}, context_{iContext} {}
133 ~EndGuard() { record_->activityRegistry()->postESModuleSignal_.emit(record_->key(), context_); }
144 exceptPtr = std::current_exception();
151 template <
typename RunModuleFnctr>
158 bool expected =
false;
170 [
this, iRecord, iEventSetupImpl, weakToken, runModuleTaskHolder =
std::move(runModuleTaskHolder)](
171 std::exception_ptr
const* iExcept)
mutable {
178 runModuleTaskHolder, iEventSetupImpl, &((*postMayGetProxies_).front()), weakToken.
lock());
180 runModuleTaskHolder.
doneWaiting(std::exception_ptr{});
192 template <
class DataT>
197 template <
class RemainingContainerT,
class DataT,
class ProductsT>
200 if (
nullptr !=
temp) {
203 if constexpr (not std::is_same_v<produce::Null, RemainingContainerT>) {
204 setData<typename RemainingContainerT::head_type, typename RemainingContainerT::tail_type>(iProducts);
230 setData<typename type::head_type, typename type::tail_type>(iReturn);
239 for (
size_t i = 0;
i !=
n; ++
i) {
CallbackBase & operator=(const CallbackBase &)=delete
ESProxyIndex const * getTokenIndices() const
void prefetchNeededDataAsync(WaitingTaskHolder task, EventSetupImpl const *iImpl, ESProxyIndex const *proxies, ServiceToken const &token) const
void exceptionContext(cms::Exception &, ESModuleCallingContext const &)
void prefetchAsync(WaitingTaskHolder iTask, ESProxyIndex iProxyIndex, EventSetupImpl const *, ServiceToken const &, ESParentContext) const
prefetch the data to setup for subsequent calls to getImplementation
PreESModulePrefetching preESModulePrefetchingSignal_
CallbackBase(T *iProd, std::shared_ptr< TProduceFunc > iProduceFunc, unsigned int iID, const TDecorator &iDec)
bool handleMayGet(EventSetupRecordImpl const *iRecord, EventSetupImpl const *iEventSetupImpl)
WaitingTaskHolder makeProduceTask(oneapi::tbb::task_group *group, ServiceWeakToken const &serviceToken, EventSetupRecordImpl const *record, EventSetupImpl const *eventSetupImpl, bool emitPostPrefetchingSignal)
void storeReturnedValues(TReturn iReturn)
void pre(const TRecord &)
void reset()
Resets access to the resource so that added tasks will wait.
WaitingTaskList taskList_
constexpr element_type const * get() const
propagate_const< T * > producer_
oneapi::tbb::task_group * group() const noexcept
void emit(Args &&... args) const
std::optional< std::vector< ESProxyIndex > > const & postMayGetProxies() const
void doneWaiting(std::exception_ptr iPtr)
Signals that the resource is now available and tasks should be spawned.
void doneWaiting(std::exception_ptr iExcept)
void setData(ProductsT &iProducts)
void holdOntoPointer(DataT *iData)
void moveFromTo(FromT &iFrom, ToT &iTo)
void add(oneapi::tbb::task_group *, WaitingTask *)
Adds task to the waiting list.
FunctorWaitingTask< F > * make_waiting_task(F f)
std::shared_ptr< TProduceFunc > const & produceFunction()
void post(const TRecord &)
ServiceToken lock() const
std::atomic< bool > wasCalledForThisRecord_
WaitingTaskList & taskList()
unsigned int transitionID() const
SerialTaskQueueChain & queue()
EventSetupRecordKey const & key() const
std::optional< std::vector< ESProxyIndex > > postMayGetProxies_
void setState(State state)
void setContext(State state, ESParentContext const &parent)
std::shared_ptr< TProduceFunc > produceFunction_
TDecorator const & decorator() const
std::array< void *, produce::size< TReturn >::value > proxyData_
auto wrap(F iFunc) -> decltype(iFunc())
ESModuleCallingContext callingContext_
ESModuleCallingContext & callingContext()
eventsetup::EventSetupRecordImpl const * findImpl(const eventsetup::EventSetupRecordKey &) const
ActivityRegistry const * activityRegistry() const noexcept
void prefetchAsyncImpl(RunModuleFnctr &&runModuleFnctr, WaitingTaskHolder iTask, EventSetupRecordImpl const *iRecord, EventSetupImpl const *iEventSetupImpl, ServiceToken const &token, ESParentContext const &iParent)