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) {
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)
Definition: Callback.h:55
WaitingTaskHolder makeProduceTask(oneapi::tbb::task_group *group, ServiceWeakToken const &serviceToken, EventSetupRecordImpl const *record, EventSetupImpl const *eventSetupImpl, bool emitPostPrefetchingSignal, ProduceFunctor &&produceFunctor)
Definition: CallbackBase.h:85
std::shared_ptr< TProduceFunc > const & produceFunction()
Definition: CallbackBase.h:231
Callback(T *iProd, TProduceFunc iProduceFunc, unsigned int iID, const TDecorator &iDec=TDecorator())
Definition: Callback.h:48
unsigned int transitionID() const
Definition: CallbackBase.h:224
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
TDecorator const & decorator() const
Definition: CallbackBase.h:232
long double T
def move(src, dest)
Definition: eostools.py:511
void prefetchAsyncImpl(RunModuleFnctr &&runModuleFnctr, WaitingTaskHolder iTask, EventSetupRecordImpl const *iRecord, EventSetupImpl const *iEventSetupImpl, ServiceToken const &token, ESParentContext const &iParent)
Definition: CallbackBase.h:163