CMS 3D CMS Logo

Callback.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 #ifndef FWCore_Framework_Callback_h
3 #define FWCore_Framework_Callback_h
4 //
5 // Package: Framework
6 // Class : Callback
7 //
15 //
16 // Author: Chris Jones
17 // Created: Sun Apr 17 14:30:24 EDT 2005
18 //
19 
20 #include <memory>
21 #include <utility>
22 
23 #include "oneapi/tbb/task_group.h"
24 
29 
30 namespace edm {
31 
32  class EventSetupImpl;
33 
34  namespace eventsetup {
35 
36  class EventSetupRecordImpl;
37 
38  template <typename T, //producer's type
39  typename TProduceFunc, //produce functor type
40  typename TReturn, //return type of the produce method
41  typename TRecord, //the record passed in as an argument
42  typename TDecorator //allows customization using pre/post calls
43  = CallbackSimpleDecorator<TRecord>>
44  class Callback : public CallbackBase<T, TProduceFunc, TReturn, TRecord, TDecorator> {
45  public:
47 
48  Callback(T* iProd, TProduceFunc iProduceFunc, unsigned int iID, const TDecorator& iDec = TDecorator())
49  : Callback(iProd, std::make_shared<TProduceFunc>(std::move(iProduceFunc)), iID, iDec) {}
50 
53  }
54 
56  EventSetupRecordImpl const* iRecord,
57  EventSetupImpl const* iEventSetupImpl,
58  ServiceToken const& token,
59  ESParentContext const& iParent) noexcept {
61  [this](auto&& group, auto&& token, auto&& record, auto&& es) {
62  constexpr bool emitPostPrefetchingSignal = true;
63  auto produceFunctor = [this](TRecord const& record) { return (*Base::produceFunction())(record); };
64  return Base::makeProduceTask(
65  group, token, record, es, emitPostPrefetchingSignal, std::move(produceFunctor));
66  },
67  std::move(iTask),
68  iRecord,
69  iEventSetupImpl,
70  token,
71  iParent);
72  }
73 
74  private:
75  Callback(T* iProd,
76  std::shared_ptr<TProduceFunc> iProduceFunc,
77  unsigned int iID,
78  const TDecorator& iDec = TDecorator())
79  : Base(iProd, std::move(iProduceFunc), iID, iDec) {}
80  };
81  } // namespace eventsetup
82 } // namespace edm
83 #endif
void prefetchAsync(WaitingTaskHolder iTask, EventSetupRecordImpl const *iRecord, EventSetupImpl const *iEventSetupImpl, ServiceToken const &token, ESParentContext const &iParent) noexcept
Definition: Callback.h:55
unsigned int transitionID() const noexcept
Definition: CallbackBase.h:224
TDecorator const & decorator() const noexcept
Definition: CallbackBase.h:232
WaitingTaskHolder makeProduceTask(oneapi::tbb::task_group *group, ServiceWeakToken const &serviceToken, EventSetupRecordImpl const *record, EventSetupImpl const *eventSetupImpl, bool emitPostPrefetchingSignal, ProduceFunctor &&produceFunctor)
Definition: CallbackBase.h:85
Callback(T *iProd, TProduceFunc iProduceFunc, unsigned int iID, const TDecorator &iDec=TDecorator())
Definition: Callback.h:48
void prefetchAsyncImpl(RunModuleFnctr &&runModuleFnctr, WaitingTaskHolder iTask, EventSetupRecordImpl const *iRecord, EventSetupImpl const *iEventSetupImpl, ServiceToken const &token, ESParentContext const &iParent) noexcept
Definition: CallbackBase.h:163
Callback * clone()
Definition: Callback.h:51
HLT enums.
Callback(T *iProd, std::shared_ptr< TProduceFunc > iProduceFunc, unsigned int iID, const TDecorator &iDec=TDecorator())
Definition: Callback.h:75
std::shared_ptr< TProduceFunc > const & produceFunction() noexcept
Definition: CallbackBase.h:231
long double T
def move(src, dest)
Definition: eostools.py:511