std::istream& operator>>(std::istream& is, OdrCompilationLogEntry& entry) { // Block I/O related exceptions auto saved_exceptions = is.exceptions();
is.exceptions(std::ios_base::iostate {});
// Write log entry. NB update OdrCompilationLog::kLogVersion if changing the format here.
is >> entry.apex_version >> std::ws;
is >> entry.last_update_millis >> std::ws;
is >> entry.trigger >> std::ws;
is >> entry.when >> std::ws;
is >> entry.exit_code >> std::ws;
// Restore I/O related exceptions
is.exceptions(saved_exceptions); return is;
}
// Block I/O related exceptions auto saved_exceptions = os.exceptions();
os.exceptions(std::ios_base::iostate {});
os << entry.apex_version << kSpace;
os << entry.last_update_millis << kSpace;
os << entry.trigger << kSpace;
os << entry.when << kSpace;
os << entry.exit_code << std::endl;
// Restore I/O related exceptions
os.exceptions(saved_exceptions); return os;
}
bool OdrCompilationLog::ShouldAttemptCompile(OdrMetrics::Trigger trigger, time_t now) const { if (entries_.size() == 0) { // We have no history, try to compile. returntrue;
}
// The backoff time is for avoiding too many failed attempts. It should not be applied if the last // compilation was successful. if (entries_.back().exit_code == ExitCode::kCompilationSuccess) { returntrue;
}
if (trigger == OdrMetrics::Trigger::kApexVersionMismatch ||
trigger == OdrMetrics::Trigger::kDexFilesChanged) { // Things have changed since the last run. returntrue;
}
// Compute the backoff time based on the number of consecutive failures. // // Wait 12 hrs * pow(2, consecutive_failures) since the last compilation attempt. staticconstint kSecondsPerDay = 86'400;
time_t backoff = kSecondsPerDay / 2; for (auto it = entries_.crbegin(); it != entries_.crend(); ++it, backoff *= 2) { if (it->exit_code == ExitCode::kCompilationSuccess) { break;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.