Restore BitTorrent session asynchronously

Reduce the total startup time of the application and maintain sufficient responsiveness of the UI during startup due to the following:
1. Load resume data from disk asynchronously in separate thread;
2. Split handling of loaded resume data in chunks;
3. Reduce the number of emitting signals.

PR #16840.
This commit is contained in:
Vladimir Golovnev
2022-07-04 12:48:21 +03:00
committed by GitHub
parent ec1d2cba40
commit be7cfb78de
25 changed files with 927 additions and 553 deletions

View File

@@ -28,6 +28,8 @@
#pragma once
#include <QReadWriteLock>
#include "base/pathfwd.h"
#include "resumedatastorage.h"
@@ -45,12 +47,14 @@ namespace BitTorrent
~DBResumeDataStorage() override;
QVector<TorrentID> registeredTorrents() const override;
std::optional<LoadTorrentParams> load(const TorrentID &id) const override;
LoadResumeDataResult load(const TorrentID &id) const override;
void store(const TorrentID &id, const LoadTorrentParams &resumeData) const override;
void remove(const TorrentID &id) const override;
void storeQueue(const QVector<TorrentID> &queue) const override;
private:
void doLoadAll() const override;
int currentDBVersion() const;
void createDB() const;
void updateDBFromVersion1() const;
@@ -59,5 +63,7 @@ namespace BitTorrent
class Worker;
Worker *m_asyncWorker = nullptr;
mutable QReadWriteLock m_dbLock;
};
}