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 //
25 
26 #include <vector>
27 #include <unordered_map>
28 #include <string>
29 #include <sstream>
30 #include <cassert>
31 
32 namespace edm {
33 
34  class EventTransitionInfo;
35  class ModuleCallingContext;
36 
38  public:
39  using worker_container = std::vector<Worker*>;
40  using const_iterator = worker_container::const_iterator;
41 
45  }
46  void addWorker(Worker* aWorker) {
47  assert(nullptr != aWorker);
48  unscheduledWorkers_.push_back(aWorker);
49  if (aWorker->hasAccumulator()) {
50  accumulatorWorkers_.push_back(aWorker);
51  }
52  }
53 
55 
56  UnscheduledAuxiliary const& auxiliary() const { return aux_; }
57 
58  const_iterator begin() const { return unscheduledWorkers_.begin(); }
59  const_iterator end() const { return unscheduledWorkers_.end(); }
60 
61  template <typename T, typename U>
63  typename T::TransitionInfoType const& info,
64  ServiceToken const& token,
65  StreamID streamID,
66  typename T::Context const* topContext,
67  U const* context) const {
68  //do nothing for event since we will run when requested
69  if (!T::isEvent_) {
70  for (auto worker : unscheduledWorkers_) {
71  ParentContext parentContext(context);
72 
73  // We do not need to run prefetching here because this only handles
74  // stream transitions for runs and lumis. There are no products put
75  // into the runs or lumis in stream transitions, so there can be
76  // no data dependencies which require prefetching. Prefetching is
77  // needed for global transitions, but they are run elsewhere.
78  worker->doWorkNoPrefetchingAsync<T>(task, info, token, streamID, parentContext, topContext);
79  }
80  }
81  }
82 
83  template <typename T>
85  typename T::TransitionInfoType const& info,
86  ServiceToken const& token,
87  StreamID streamID,
88  ParentContext const& parentContext,
89  typename T::Context const* context) {
90  for (auto worker : accumulatorWorkers_) {
91  worker->doWorkAsync<T>(task, info, token, streamID, parentContext, context);
92  }
93  }
94 
95  private:
96  template <typename T, typename ID>
97  void addContextToException(cms::Exception& ex, Worker const* worker, ID const& id) const {
98  std::ostringstream ost;
99  ost << "Processing " << T::transitionName() << " " << id;
100  ex.addContext(ost.str());
101  }
105  };
106 
107 } // namespace edm
108 
109 #endif
edm::UnscheduledCallProducer::addContextToException
void addContextToException(cms::Exception &ex, Worker const *worker, ID const &id) const
Definition: UnscheduledCallProducer.h:97
edm::EventTransitionInfo
Definition: TransitionInfoTypes.h:26
edm::StreamID
Definition: StreamID.h:30
edm::UnscheduledCallProducer::UnscheduledCallProducer
UnscheduledCallProducer(ActivityRegistry &iReg)
Definition: UnscheduledCallProducer.h:42
edm::UnscheduledCallProducer
Definition: UnscheduledCallProducer.h:37
edm::UnscheduledCallProducer::runNowAsync
void runNowAsync(WaitingTask *task, typename T::TransitionInfoType const &info, ServiceToken const &token, StreamID streamID, typename T::Context const *topContext, U const *context) const
Definition: UnscheduledCallProducer.h:62
cms::Exception::addContext
void addContext(std::string const &context)
Definition: Exception.cc:165
edm
HLT enums.
Definition: AlignableModifier.h:19
cms::cuda::assert
assert(be >=bs)
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
ActivityRegistry.h
BranchActionType.h
edm::ServiceToken
Definition: ServiceToken.h:40
edm::UnscheduledCallProducer::aux_
UnscheduledAuxiliary aux_
Definition: UnscheduledCallProducer.h:104
edm::UnscheduledCallProducer::const_iterator
worker_container::const_iterator const_iterator
Definition: UnscheduledCallProducer.h:40
TrackValidation_cff.task
task
Definition: TrackValidation_cff.py:252
edm::ActivityRegistry
Definition: ActivityRegistry.h:133
edm::UnscheduledCallProducer::setEventTransitionInfo
void setEventTransitionInfo(EventTransitionInfo const &info)
Definition: UnscheduledCallProducer.h:54
edm::Worker
Definition: Worker.h:88
edm::UnscheduledAuxiliary::preModuleDelayedGetSignal_
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> preModuleDelayedGetSignal_
Definition: UnscheduledAuxiliary.h:43
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
edm::ParentContext
Definition: ParentContext.h:27
edm::ActivityRegistry::postModuleEventDelayedGetSignal_
PostModuleEventDelayedGet postModuleEventDelayedGetSignal_
Definition: ActivityRegistry.h:763
edm::UnscheduledAuxiliary::setEventTransitionInfo
void setEventTransitionInfo(EventTransitionInfo const &info)
Definition: UnscheduledAuxiliary.h:41
align::ID
uint32_t ID
Definition: Definitions.h:24
edm::UnscheduledCallProducer::addWorker
void addWorker(Worker *aWorker)
Definition: UnscheduledCallProducer.h:46
UnscheduledAuxiliary.h
edm::UnscheduledCallProducer::begin
const_iterator begin() const
Definition: UnscheduledCallProducer.h:58
edm::ActivityRegistry::preModuleEventDelayedGetSignal_
PreModuleEventDelayedGet preModuleEventDelayedGetSignal_
Definition: ActivityRegistry.h:755
edm::UnscheduledAuxiliary
Definition: UnscheduledAuxiliary.h:33
edm::UnscheduledCallProducer::worker_container
std::vector< Worker * > worker_container
Definition: UnscheduledCallProducer.h:39
OccurrenceTraits.h
ParentContext.h
edm::WaitingTask
Definition: WaitingTask.h:36
edm::UnscheduledCallProducer::auxiliary
UnscheduledAuxiliary const & auxiliary() const
Definition: UnscheduledCallProducer.h:56
Frameworkfwd.h
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
T
long double T
Definition: Basic3DVectorLD.h:48
edm::Worker::hasAccumulator
virtual bool hasAccumulator() const =0
edm::UnscheduledCallProducer::runAccumulatorsAsync
void runAccumulatorsAsync(WaitingTask *task, typename T::TransitionInfoType const &info, ServiceToken const &token, StreamID streamID, ParentContext const &parentContext, typename T::Context const *context)
Definition: UnscheduledCallProducer.h:84
Worker.h
edm::UnscheduledCallProducer::end
const_iterator end() const
Definition: UnscheduledCallProducer.h:59
edm::UnscheduledAuxiliary::postModuleDelayedGetSignal_
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> postModuleDelayedGetSignal_
Definition: UnscheduledAuxiliary.h:44
edm::signalslot::Signal::connect
void connect(U iFunc)
Definition: Signal.h:64
edm::UnscheduledCallProducer::accumulatorWorkers_
worker_container accumulatorWorkers_
Definition: UnscheduledCallProducer.h:103
cms::Exception
Definition: Exception.h:70
edm::UnscheduledCallProducer::unscheduledWorkers_
worker_container unscheduledWorkers_
Definition: UnscheduledCallProducer.h:102
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:318