mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-06 05:01:25 -07:00
Provide asynchronous results via QFuture
Makes asynchronous logic to look more straightforward. Allows caller to choose blocking or non-blocking way of obtaining asynchronous results via the same interface. PR #22598.
This commit is contained in:
parent
33aaa867b5
commit
732b2bcbdb
15 changed files with 165 additions and 223 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2018-2023 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2018-2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -32,6 +32,7 @@
|
|||
#include <functional>
|
||||
|
||||
#include <QBitArray>
|
||||
#include <QFuture>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QList>
|
||||
|
@ -180,9 +181,11 @@ namespace
|
|||
QJsonArray getStickyTrackers(const BitTorrent::Torrent *const torrent)
|
||||
{
|
||||
int seedsDHT = 0, seedsPeX = 0, seedsLSD = 0, leechesDHT = 0, leechesPeX = 0, leechesLSD = 0;
|
||||
for (const BitTorrent::PeerInfo &peer : asConst(torrent->peers()))
|
||||
const QList<BitTorrent::PeerInfo> peersList = torrent->fetchPeerInfo().takeResult();
|
||||
for (const BitTorrent::PeerInfo &peer : peersList)
|
||||
{
|
||||
if (peer.isConnecting()) continue;
|
||||
if (peer.isConnecting())
|
||||
continue;
|
||||
|
||||
if (peer.isSeed())
|
||||
{
|
||||
|
@ -727,7 +730,7 @@ void TorrentsController::filesAction()
|
|||
{
|
||||
const QList<BitTorrent::DownloadPriority> priorities = torrent->filePriorities();
|
||||
const QList<qreal> fp = torrent->filesProgress();
|
||||
const QList<qreal> fileAvailability = torrent->availableFileFractions();
|
||||
const QList<qreal> fileAvailability = torrent->fetchAvailableFileFractions().takeResult();
|
||||
const BitTorrent::TorrentInfo info = torrent->info();
|
||||
for (const int index : asConst(fileIndexes))
|
||||
{
|
||||
|
@ -796,7 +799,7 @@ void TorrentsController::pieceStatesAction()
|
|||
for (int i = 0; i < states.size(); ++i)
|
||||
pieceStates.append(static_cast<int>(states[i]) * 2);
|
||||
|
||||
const QBitArray dlstates = torrent->downloadingPieces();
|
||||
const QBitArray dlstates = torrent->fetchDownloadingPieces().takeResult();
|
||||
for (int i = 0; i < states.size(); ++i)
|
||||
{
|
||||
if (dlstates[i])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue