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  worker_container const& workers() const { return unscheduledWorkers_; }
69 
70  template <typename T, typename U>
72  typename T::TransitionInfoType const& info,
73  ServiceToken const& token,
74  StreamID streamID,
75  typename T::Context const* topContext,
76  U const* context) const {
77  //do nothing for event since we will run when requested
78  if (!T::isEvent_) {
79  for (auto worker : unscheduledWorkers_) {
80  ParentContext parentContext(context);
81 
82  // We do not need to run prefetching here because this only handles
83  // stream transitions for runs and lumis. There are no products put
84  // into the runs or lumis in stream transitions, so there can be
85  // no data dependencies which require prefetching. Prefetching is
86  // needed for global transitions, but they are run elsewhere.
87  worker->doWorkNoPrefetchingAsync<T>(task, info, token, streamID, parentContext, topContext);
88  }
89  }
90  }
91 
92  template <typename T>
94  typename T::TransitionInfoType const& info,
95  ServiceToken const& token,
96  StreamID streamID,
97  ParentContext const& parentContext,
98  typename T::Context const* context) {
99  for (auto worker : accumulatorWorkers_) {
100  worker->doWorkAsync<T>(task, info, token, streamID, parentContext, context);
101  }
102  }
103 
104  private:
105  template <typename T, typename ID>
106  void addContextToException(cms::Exception& ex, Worker const* worker, ID const& id) const {
107  std::ostringstream ost;
108  ost << "Processing " << T::transitionName() << " " << id;
109  ex.addContext(ost.str());
110  }
114  };
115 
116 } // namespace edm
117 
118 #endif
std::string_view transitionName(GlobalContext::Transition)
PostModuleEventDelayedGet postModuleEventDelayedGetSignal_
PreModuleEventDelayedGet preModuleEventDelayedGetSignal_
static const TGPicture * info(bool iBackgroundIsBlack)
virtual bool hasAccumulator() const =0
void removeWorker(Worker const *worker)
worker_container const & workers() const
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:169
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)