2 #ifndef FWCore_Framework_CallbackExternalWork_h 3 #define FWCore_Framework_CallbackExternalWork_h 25 #include "oneapi/tbb/task_group.h" 47 namespace eventsetup {
52 using type = std::optional<U>;
57 using type = std::optional<U>;
62 using type = std::unique_ptr<U>;
67 using type = std::shared_ptr<U>;
73 typename TAcquireFunc,
74 typename TAcquireReturn,
75 typename TProduceFunc,
76 typename TProduceReturn,
79 = CallbackSimpleDecorator<TRecord>>
85 TAcquireFunc iAcquireFunc,
86 TProduceFunc iProduceFunc,
88 const TDecorator& iDec = TDecorator())
90 std::make_shared<TAcquireFunc>(
std::
move(iAcquireFunc)),
91 std::make_shared<TProduceFunc>(
std::
move(iProduceFunc)),
107 constexpr
bool emitPostPrefetchingSignal =
false;
108 auto produceFunctor = [
this](TRecord
const&
record) {
131 std::shared_ptr<TAcquireFunc> iAcquireFunc,
132 std::shared_ptr<TProduceFunc> iProduceFunc,
134 const TDecorator& iDec = TDecorator())
138 oneapi::tbb::task_group*
group,
145 [
this, holder =
std::move(waitingTaskWithArenaHolder),
group, serviceToken,
record, eventSetupImpl](
146 std::exception_ptr
const* iException)
mutable {
147 std::exception_ptr excptr;
149 excptr = *iException;
154 record->activityRegistry()->postESModulePrefetchingSignal_.emit(
record->key(),
160 excptr = std::current_exception();
171 std::exception_ptr exceptPtr;
186 : record_{iRecord}, context_{iContext} {}
188 record_->activityRegistry()->postESModuleAcquireSignal_.emit(record_->key(), context_);
198 exceptPtr = std::current_exception();
200 holder.doneWaiting(exceptPtr);
206 oneapi::tbb::task_group*
group) {
209 std::exception_ptr
const* iException)
mutable {
210 std::exception_ptr excptr;
212 excptr = *iException;
218 exception.addContext(
"Running acquire and external work");
CallbackExternalWork(T *iProd, TAcquireFunc iAcquireFunc, TProduceFunc iProduceFunc, unsigned int iID, const TDecorator &iDec=TDecorator())
void exceptionContext(cms::Exception &, ESModuleCallingContext const &)
static std::shared_ptr< U > & value(type &val)
static std::unique_ptr< U > & value(type &val)
std::shared_ptr< TAcquireFunc > acquireFunction_
std::optional< std::vector< ESResolverIndex > > const & postMayGetResolvers() const
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
CallbackExternalWork(T *iProd, std::shared_ptr< TAcquireFunc > iAcquireFunc, std::shared_ptr< TProduceFunc > iProduceFunc, unsigned int iID, const TDecorator &iDec=TDecorator())
WaitingTaskHolder makeProduceTask(oneapi::tbb::task_group *group, ServiceWeakToken const &serviceToken, EventSetupRecordImpl const *record, EventSetupImpl const *eventSetupImpl, bool emitPostPrefetchingSignal, ProduceFunctor &&produceFunctor)
std::shared_ptr< U > type
void doneWaiting(std::exception_ptr iPtr)
Signals that the resource is now available and tasks should be spawned.
void doneWaiting(std::exception_ptr iExcept)
FunctorWaitingTask< F > * make_waiting_task(F f)
std::shared_ptr< TProduceFunc > const & produceFunction()
ServiceToken lock() const
WaitingTaskList & taskList()
WaitingTaskWithArenaHolder makeExceptionHandlerTask(WaitingTaskHolder produceTask, oneapi::tbb::task_group *group)
unsigned int transitionID() const
SerialTaskQueueChain & queue()
void prefetchAsync(WaitingTaskHolder iTask, EventSetupRecordImpl const *iRecord, EventSetupImpl const *iEventSetupImpl, ServiceToken const &token, ESParentContext const &iParent)
static std::optional< U > & value(type &val)
void setState(State state)
void addContext(std::string const &context)
ESResolverIndex const * getTokenIndices() const
impl::AcquireCacheType< TAcquireReturn >::type acquireCache_
std::unique_ptr< U > type
TDecorator const & decorator() const
CallbackExternalWork * clone()
auto wrap(F iFunc) -> decltype(iFunc())
ESModuleCallingContext & callingContext()
std::optional< TAcquireReturn > type
static U & value(type &val)
WaitingTaskHolder makeAcquireTask(WaitingTaskWithArenaHolder waitingTaskWithArenaHolder, oneapi::tbb::task_group *group, ServiceWeakToken const &serviceToken, EventSetupRecordImpl const *record, EventSetupImpl const *eventSetupImpl)
void prefetchAsyncImpl(RunModuleFnctr &&runModuleFnctr, WaitingTaskHolder iTask, EventSetupRecordImpl const *iRecord, EventSetupImpl const *iEventSetupImpl, ServiceToken const &token, ESParentContext const &iParent)
void push(oneapi::tbb::task_group &iGroup, T &&iAction)
asynchronously pushes functor iAction into queue