forked from cms-patatrack/pixeltrack-standalone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EventProcessor.cc
47 lines (42 loc) · 1.63 KB
/
EventProcessor.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "Framework/EmptyWaitingTask.h"
#include "Framework/ESPluginFactory.h"
#include "Framework/WaitingTask.h"
#include "Framework/WaitingTaskHolder.h"
#include "EventProcessor.h"
namespace edm {
EventProcessor::EventProcessor(int maxEvents,
int runForMinutes,
int numberOfStreams,
std::vector<std::string> const& path,
std::vector<std::string> const& esproducers,
std::filesystem::path const& datadir,
bool validation)
: source_(maxEvents, runForMinutes, registry_, datadir, validation) {
for (auto const& name : esproducers) {
pluginManager_.load(name);
auto esp = ESPluginFactory::create(name, datadir);
esp->produce(eventSetup_);
}
//schedules_.reserve(numberOfStreams);
for (int i = 0; i < numberOfStreams; ++i) {
schedules_.emplace_back(registry_, pluginManager_, &source_, &eventSetup_, i, path);
}
}
void EventProcessor::runToCompletion() {
source_.startProcessing();
// The task that waits for all other work
auto globalWaitTask = make_empty_waiting_task();
globalWaitTask->increment_ref_count();
for (auto& s : schedules_) {
s.runToCompletionAsync(WaitingTaskHolder(globalWaitTask.get()));
}
globalWaitTask->wait_for_all();
if (globalWaitTask->exceptionPtr()) {
std::rethrow_exception(*(globalWaitTask->exceptionPtr()));
}
}
void EventProcessor::endJob() {
// Only on the first stream...
schedules_[0].endJob();
}
} // namespace edm