CMS 3D CMS Logo

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)
void addContextToException(cms::Exception &ex, Worker const *worker, ID const &id) const
void setEventTransitionInfo(EventTransitionInfo const &info)
UnscheduledCallProducer(ActivityRegistry &iReg)
uint32_t ID
Definition: Definitions.h:24
void runNowAsync(WaitingTaskHolder task, typename T::TransitionInfoType const &info, ServiceToken const &token, StreamID streamID, typename T::Context const *topContext, U const *context) const
std::vector< Worker * > worker_container
assert(be >=bs)
void setEventTransitionInfo(EventTransitionInfo const &info)
UnscheduledAuxiliary const & auxiliary() const
void addContext(std::string const &context)
Definition: Exception.cc:165
def remove(d, key, TELL=False)
Definition: MatrixUtil.py:223
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> preModuleDelayedGetSignal_
HLT enums.
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)