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)
84 template <
typename ProduceFunctor>
89 bool emitPostPrefetchingSignal,
90 ProduceFunctor&& produceFunctor) {
98 emitPostPrefetchingSignal,
100 std::forward<ProduceFunctor>(produceFunctor)](std::exception_ptr
const* iException) {
101 std::exception_ptr excptr;
103 excptr = *iException;
105 if (emitPostPrefetchingSignal) {
114 excptr = std::current_exception();
124 *
group, [
this, serviceToken,
record, eventSetupImpl, produceFunctor =
std::move(produceFunctor)]() {
126 std::exception_ptr exceptPtr;
132 proxies = &((*postMayGetResolvers_).front());
141 : record_{iRecord}, context_{iContext} {}
143 record_->activityRegistry()->postESModuleSignal_.emit(record_->key(), context_);
155 exceptPtr = std::current_exception();
162 template <
typename RunModuleFnctr>
169 bool expected =
false;
181 [
this, iRecord, iEventSetupImpl, weakToken, runModuleTaskHolder =
std::move(runModuleTaskHolder)](
182 std::exception_ptr
const* iExcept)
mutable {
189 runModuleTaskHolder, iEventSetupImpl, &((*postMayGetResolvers_).front()), weakToken.
lock());
191 runModuleTaskHolder.
doneWaiting(std::exception_ptr{});
203 template <
class DataT>
208 template <
class RemainingContainerT,
class DataT,
class ProductsT>
211 if (
nullptr !=
temp) {
214 if constexpr (not std::is_same_v<produce::Null, RemainingContainerT>) {
215 setData<typename RemainingContainerT::head_type, typename RemainingContainerT::tail_type>(iProducts);
241 setData<typename type::head_type, typename type::tail_type>(iReturn);
250 for (
size_t i = 0;
i !=
n; ++
i) {
CallbackBase & operator=(const CallbackBase &)=delete
void exceptionContext(cms::Exception &, ESModuleCallingContext const &)
void prefetchAsync(WaitingTaskHolder iTask, ESResolverIndex iResolverIndex, 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)
void storeReturnedValues(TReturn iReturn)
void pre(const TRecord &)
std::optional< std::vector< ESResolverIndex > > const & postMayGetResolvers() const
void reset()
Resets access to the resource so that added tasks will wait.
WaitingTaskHolder makeProduceTask(oneapi::tbb::task_group *group, ServiceWeakToken const &serviceToken, EventSetupRecordImpl const *record, EventSetupImpl const *eventSetupImpl, bool emitPostPrefetchingSignal, ProduceFunctor &&produceFunctor)
WaitingTaskList taskList_
constexpr element_type const * get() const
propagate_const< T * > producer_
oneapi::tbb::task_group * group() const noexcept
void emit(Args &&... args) 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 prefetchNeededDataAsync(WaitingTaskHolder task, EventSetupImpl const *iImpl, ESResolverIndex const *proxies, ServiceToken const &token) const
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()
std::optional< std::vector< ESResolverIndex > > postMayGetResolvers_
EventSetupRecordKey const & key() const
void setState(State state)
ESResolverIndex const * getTokenIndices() const
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)