Commit f42149a8 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

return fast if no feed is fetching

parent 185fd36c
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -165,6 +165,7 @@ void RemoteFeedReader::maybeFillBuffer(SourceFeed* source) {
void RemoteFeedReader::waitForNextEntry() {
  ScopedLock<std::mutex> lk(mutex_);
  bool is_data_available = false;
  bool is_any_fetching = false;

  for (const auto& source : sources_) {
    maybeFillBuffer(source.get());
@@ -172,6 +173,10 @@ void RemoteFeedReader::waitForNextEntry() {
    if (source->read_buffer.size() > 0) {
      is_data_available = true;
    }

    if (source->is_fetching) {
      is_any_fetching = true;
    }
  }

  /* fastpath if there is data available on any feed */
@@ -179,6 +184,10 @@ void RemoteFeedReader::waitForNextEntry() {
    return;
  }

  if (!is_any_fetching) {
    return;
  }

  auto wakeup_gen = data_available_wakeup_.generation();
  lk.unlock();