diff options
| author | Jeremy Rimpo <jeremy.rimpo@servermonkey.com> | 2021-12-16 22:04:41 -0600 |
|---|---|---|
| committer | Mikaƫl Capelle <capelle.mikael@gmail.com> | 2022-04-19 15:17:43 +0200 |
| commit | 05d01e39fa15bfd3395ac89ea6a1f2acb9a4dea6 (patch) | |
| tree | 465ea38e70e4ee2da4a0ebad1c8dfc334b11a4c5 /src/downloadmanager.h | |
| parent | 2017700eedf4b9585d0389b5b4a94883e8237c38 (diff) | |
Download status improvements
- Better speed calculation
- Add download time estimate
Diffstat (limited to 'src/downloadmanager.h')
| -rw-r--r-- | src/downloadmanager.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/downloadmanager.h b/src/downloadmanager.h index ba9f4b5c..86dc17b9 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -38,6 +38,10 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include <QFileSystemWatcher> #include <QSettings> #include <boost/signals2.hpp> +#include <boost/accumulators/accumulators.hpp> +#include <boost/accumulators/statistics.hpp> +#include <boost/accumulators/statistics/rolling_mean.hpp> +using namespace boost::accumulators; namespace MOBase { class IPluginGame; } @@ -75,6 +79,10 @@ private: struct DownloadInfo { ~DownloadInfo() { delete m_FileInfo; } + accumulator_set<int, stats<tag::rolling_mean>> m_DownloadAcc; + accumulator_set<int, stats<tag::rolling_mean>> m_DownloadTimeAcc; + int m_DownloadLast; + int m_DownloadTimeLast; unsigned int m_DownloadID; QString m_FileName; QFile m_Output; @@ -82,7 +90,6 @@ private: QElapsedTimer m_StartTime; qint64 m_PreResumeSize; std::pair<int, QString> m_Progress; - std::tuple<int, int, int, int, int> m_SpeedDiff; bool m_HasData; DownloadState m_State; int m_CurrentUrl; @@ -126,7 +133,10 @@ private: private: static unsigned int s_NextDownloadID; private: - DownloadInfo() : m_TotalSize(0), m_ReQueried(false), m_Hidden(false), m_SpeedDiff(std::tuple<int,int,int,int,int>(0,0,0,0,0)), m_HasData(false) {} + DownloadInfo() : m_TotalSize(0), m_ReQueried(false), m_Hidden(false), m_HasData(false), + m_DownloadTimeLast(0), m_DownloadLast(0), + m_DownloadAcc(tag::rolling_window::window_size = 500), + m_DownloadTimeAcc(tag::rolling_window::window_size = 500) {} }; friend class DownloadManagerProxy; |
