Skip to content

Commit 515fdc5

Browse files
Dan RileyDan Riley
authored andcommitted
minor improvements from comments
1 parent e16f1b5 commit 515fdc5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

FWCore/Modules/src/TimeStudyModules.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ namespace timestudy {
215215
void asyncWork(
216216
edm::StreamID id, edm::WaitingTaskWithArenaHolder iTask, long initTime, long workTime, long finishTime) {
217217
waitTimesPerStream_[id.value()] = {{initTime, workTime, finishTime}};
218-
waitingTaskPerStream_[id.value()] = std::move(iTask);
218+
waitingTaskPerStream_.at(id.value()) = std::move(iTask);
219219
{
220220
std::lock_guard<std::mutex> lk{mutex_};
221221
waitingStreams_.push_back(id.value());
@@ -231,14 +231,15 @@ namespace timestudy {
231231
if (waitingStreams_.size() >= nWaitingEvents_) {
232232
return true;
233233
}
234-
//every running stream is now waiting
234+
//every running stream is now waiting but guard against spurious wakeups
235235
return !waitingStreams_.empty() and waitingStreams_.size() == activeStreams_;
236236
}
237237

238238
void threadWork() {
239239
while (not stopProcessing_.load()) {
240240
std::vector<int> streamsToProcess;
241-
streamsToProcess.reserve(waitingStreams_.capacity());
241+
// preallocate to fixed size so there are no resizes
242+
streamsToProcess.reserve(waitTimesPerStream_.size());
242243
{
243244
std::unique_lock<std::mutex> lk(mutex_);
244245
condition_.wait(lk, [this]() { return readyToDoSomething(); });

0 commit comments

Comments
 (0)