Browse Source

Use alert's timestamp

This way has better accuracy than running our own timer.
adaptive-webui-19844
Chocobo1 6 years ago
parent
commit
39830986c2
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 5
      src/base/bittorrent/session.cpp
  2. 3
      src/base/bittorrent/session.h

5
src/base/bittorrent/session.cpp

@ -508,7 +508,6 @@ Session::Session(QObject *parent) @@ -508,7 +508,6 @@ Session::Session(QObject *parent)
new PortForwarderImpl {m_nativeSession};
initMetrics();
m_statsUpdateTimer.start();
qDebug("* BitTorrent Session constructed");
}
@ -4207,7 +4206,9 @@ void Session::handleExternalIPAlert(const lt::external_ip_alert *p) @@ -4207,7 +4206,9 @@ void Session::handleExternalIPAlert(const lt::external_ip_alert *p)
void Session::handleSessionStatsAlert(const lt::session_stats_alert *p)
{
const qreal interval = m_statsUpdateTimer.restart() / 1000.;
const qreal interval = lt::total_milliseconds(p->timestamp() - m_statsLastTimestamp) / 1000.;
m_statsLastTimestamp = p->timestamp();
#if (LIBTORRENT_VERSION_NUM < 10200)
const auto &stats = p->values;
#else

3
src/base/bittorrent/session.h

@ -34,7 +34,6 @@ @@ -34,7 +34,6 @@
#include <libtorrent/fwd.hpp>
#include <QElapsedTimer>
#include <QFile>
#include <QHash>
#include <QList>
@ -701,7 +700,7 @@ namespace BitTorrent @@ -701,7 +700,7 @@ namespace BitTorrent
QTimer *m_recentErroredTorrentsTimer;
SessionMetricIndices m_metricIndices;
QElapsedTimer m_statsUpdateTimer;
lt::time_point m_statsLastTimestamp = lt::clock_type::now();
SessionStatus m_status;
CacheStatus m_cacheStatus;

Loading…
Cancel
Save