Properly use the extra delay in all cases

This commit is contained in:
King_DuckZ 2020-09-04 15:10:24 +01:00
parent a5e2c14171
commit 3b071727c3

View file

@ -27,15 +27,15 @@ namespace duck {
namespace {
[[gnu::pure]]
unsigned long time_interval (const oro::Header& header) {
return header.retry_after / header.rate_limit;
unsigned long time_interval (const oro::Header& header, double extra) {
return header.retry_after / header.rate_limit + extra;
}
oro::Timestamp calc_next_update (const oro::Header& header) {
oro::Timestamp calc_next_update (const oro::Header& header, double extra) {
oro::Timestamp ret;
ret.ts =
std::chrono::time_point_cast<oro::timestamp_t::duration>(std::chrono::system_clock::now()) +
std::chrono::seconds(time_interval(header));
std::chrono::seconds(time_interval(header, extra));
return ret;
}
@ -75,7 +75,7 @@ void TimerBase::on_timer() {
}
void TimerBase::set_next_timer (const oro::Header& header) {
const unsigned long next_timer = time_interval(header) + m_extra_delay;
const unsigned long next_timer = time_interval(header, m_extra_delay);
std::cout << "Next timer in " << next_timer << " secs\n";
this->set_timer(static_cast<double>(next_timer));
}
@ -96,19 +96,19 @@ oro::OriginsDB& TimerBase::db() {
}
void TimerBase::update_db (const oro::Shops& shops, const oro::Header& header) {
db().update(shops, calc_next_update(header));
db().update(shops, calc_next_update(header, m_extra_delay));
}
void TimerBase::update_db (const oro::Items& items, const oro::Header& header) {
db().update(items, calc_next_update(header));
db().update(items, calc_next_update(header, m_extra_delay));
}
void TimerBase::update_db (const oro::Icons& icons, const oro::Header& header) {
db().update(icons, calc_next_update(header));
db().update(icons, calc_next_update(header, m_extra_delay));
}
void TimerBase::update_db (const oro::Creators& creators, const oro::Header& header) {
db().update(creators, calc_next_update(header));
db().update(creators, calc_next_update(header, m_extra_delay));
}
} //namespace duck