CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
UnscheduledCallProducer.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_UnscheduledCallProducer_h
2 #define FWCore_Framework_UnscheduledCallProducer_h
3 
4 // -*- C++ -*-
5 //
6 // Package: FWCore/Framework
7 // Class : UnscheduledCallProducer
8 //
26 
27 #include <vector>
28 #include <unordered_map>
29 #include <string>
30 #include <sstream>
31 #include <cassert>
32 
33 namespace edm {
34 
35  class EventTransitionInfo;
36  class ModuleCallingContext;
37 
39  public:
40  using worker_container = std::vector<Worker*>;
41  using const_iterator = worker_container::const_iterator;
42 
46  }
47  void addWorker(Worker* aWorker) {
48  assert(nullptr != aWorker);
49  unscheduledWorkers_.push_back(aWorker);
50  if (aWorker->hasAccumulator()) {
51  accumulatorWorkers_.push_back(aWorker);
52  }
53  }
54 
55  void removeWorker(Worker const* worker) {
57  unscheduledWorkers_.end());
59  accumulatorWorkers_.end());
60  }
61 
63 
64  UnscheduledAuxiliary const& auxiliary() const { return aux_; }
65 
66  const_iterator begin() const { return unscheduledWorkers_.begin(); }
67  const_iterator end() const { return unscheduledWorkers_.end(); }
68 
69  template <typename T, typename U>
71  typename T::TransitionInfoType const& info,
72  ServiceToken const& token,
73  StreamID streamID,
74  typename T::Context const* topContext,
75  U const* context) const {
76  //do nothing for event since we will run when requested
77  if (!T::isEvent_) {
78  for (auto worker : unscheduledWorkers_) {
79  ParentContext parentContext(context);
80 
81  // We do not need to run prefetching here because this only handles
82  // stream transitions for runs and lumis. There are no products put
83  // into the runs or lumis in stream transitions, so there can be
84  // no data dependencies which require prefetching. Prefetching is
85  // needed for global transitions, but they are run elsewhere.
86  worker->doWorkNoPrefetchingAsync<T>(task, info, token, streamID, parentContext, topContext);
87  }
88  }
89  }
90 
91  template <typename T>
93  typename T::TransitionInfoType const& info,
94  ServiceToken const& token,
95  StreamID streamID,
96  ParentContext const& parentContext,
97  typename T::Context const* context) {
98  for (auto worker : accumulatorWorkers_) {
99  worker->doWorkAsync<T>(task, info, token, streamID, parentContext, context);
100  }
101  }
102 
103  private:
104  template <typename T, typename ID>
105  void addContextToException(cms::Exception& ex, Worker const* worker, ID const& id) const {
106  std::ostringstream ost;
107  ost << "Processing " << T::transitionName() << " " << id;
108  ex.addContext(ost.str());
109  }
113  };
114 
115 } // namespace edm
116 
117 #endif
PostModuleEventDelayedGet postModuleEventDelayedGetSignal_
PreModuleEventDelayedGet preModuleEventDelayedGetSignal_
static const TGPicture * info(bool iBackgroundIsBlack)
virtual bool hasAccumulator() const =0
void removeWorker(Worker const *worker)
uint16_t *__restrict__ id
void setEventTransitionInfo(EventTransitionInfo const &info)
UnscheduledCallProducer(ActivityRegistry &iReg)
uint32_t ID
Definition: Definitions.h:24
std::vector< Worker * > worker_container
void runNowAsync(WaitingTaskHolder task, typename T::TransitionInfoType const &info, ServiceToken const &token, StreamID streamID, typename T::Context const *topContext, U const *context) const
assert(be >=bs)
void setEventTransitionInfo(EventTransitionInfo const &info)
void addContextToException(cms::Exception &ex, Worker const *worker, ID const &id) const
UnscheduledAuxiliary const & auxiliary() const
void addContext(std::string const &context)
Definition: Exception.cc:165
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> preModuleDelayedGetSignal_
worker_container::const_iterator const_iterator
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> postModuleDelayedGetSignal_
long double T
void connect(U iFunc)
Definition: Signal.h:64
void runAccumulatorsAsync(WaitingTaskHolder task, typename T::TransitionInfoType const &info, ServiceToken const &token, StreamID streamID, ParentContext const &parentContext, typename T::Context const *context)