webrtc/logging/rtc_event_log/rtc_event_processor.cc
Artem Titov af9a3c6676 Use backticks not vertical bars to denote variables in comments for /logging
Bug: webrtc:12338
Change-Id: I87d33f201d4acfb26ca1d2da8a52cc188ff2c791
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226948
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34609}
2021-07-30 19:19:34 +00:00

41 lines
1.5 KiB
C++

/*
* Copyright 2019 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "logging/rtc_event_log/rtc_event_processor.h"
namespace webrtc {
RtcEventProcessor::RtcEventProcessor() = default;
RtcEventProcessor::~RtcEventProcessor() = default;
void RtcEventProcessor::ProcessEventsInOrder() {
// `event_lists_` is a min-heap of lists ordered by the timestamp of the
// first element in the list. We therefore process the first element of the
// first list, then reinsert the remainder of that list into the heap
// if the list still contains unprocessed elements.
while (!event_lists_.empty()) {
event_lists_.front()->ProcessNext();
std::pop_heap(event_lists_.begin(), event_lists_.end(), Cmp);
if (event_lists_.back()->IsEmpty()) {
event_lists_.pop_back();
} else {
std::push_heap(event_lists_.begin(), event_lists_.end(), Cmp);
}
}
}
bool RtcEventProcessor::Cmp(const RtcEventProcessor::ListPtrType& a,
const RtcEventProcessor::ListPtrType& b) {
int64_t time_diff = a->GetNextTime() - b->GetNextTime();
if (time_diff == 0)
return a->GetTieBreaker() > b->GetTieBreaker();
return time_diff > 0;
}
} // namespace webrtc