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;
173 auto group = iTask.group();
177 iRecord->activityRegistry()->preESModulePrefetchingSignal_.emit(iRecord->key(),
callingContext_);
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) {
251 auto rec = iImpl->findImpl(recs[
i]);
CallbackBase & operator=(const CallbackBase &)=delete
unsigned int transitionID() const noexcept
void exceptionContext(cms::Exception &, ESModuleCallingContext const &)
TDecorator const & decorator() const noexcept
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)
SerialTaskQueueChain & queue() noexcept
void prefetchNeededDataAsync(WaitingTaskHolder task, EventSetupImpl const *iImpl, ESResolverIndex const *proxies, ServiceToken const &token) const noexcept
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_
void doneWaiting(std::exception_ptr iPtr)
Signals that the resource is now available and tasks should be spawned.
ESModuleCallingContext & callingContext() noexcept
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)
WaitingTaskList & taskList() noexcept
void post(const TRecord &)
ServiceToken lock() const
std::atomic< bool > wasCalledForThisRecord_
void doneWaiting(std::exception_ptr iExcept) noexcept
std::optional< std::vector< ESResolverIndex > > postMayGetResolvers_
void setState(State state)
void prefetchAsyncImpl(RunModuleFnctr &&runModuleFnctr, WaitingTaskHolder iTask, EventSetupRecordImpl const *iRecord, EventSetupImpl const *iEventSetupImpl, ServiceToken const &token, ESParentContext const &iParent) noexcept
void setContext(State state, ESParentContext const &parent)
ESResolverIndex const * getTokenIndices() const noexcept
std::shared_ptr< TProduceFunc > produceFunction_
std::array< void *, produce::size< TReturn >::value > proxyData_
auto wrap(F iFunc) -> decltype(iFunc())
std::shared_ptr< TProduceFunc > const & produceFunction() noexcept
ESModuleCallingContext callingContext_