mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-29 05:48:47 +03:00
Add async io threads option to AdvancedSettings
This commit is contained in:
parent
553bd8e22c
commit
670a8e27af
4 changed files with 36 additions and 1 deletions
|
@ -274,6 +274,7 @@ Session::Session(QObject *parent)
|
|||
, m_IPFilterFile(BITTORRENT_SESSION_KEY("IPFilter"))
|
||||
, m_announceToAllTrackers(BITTORRENT_SESSION_KEY("AnnounceToAllTrackers"), false)
|
||||
, m_announceToAllTiers(BITTORRENT_SESSION_KEY("AnnounceToAllTiers"), true)
|
||||
, m_asyncIOThreads(BITTORRENT_SESSION_KEY("AsyncIOThreadsCount"), 4)
|
||||
, m_diskCacheSize(BITTORRENT_SESSION_KEY("DiskCacheSize"), 64)
|
||||
, m_diskCacheTTL(BITTORRENT_SESSION_KEY("DiskCacheTTL"), 60)
|
||||
, m_useOSCache(BITTORRENT_SESSION_KEY("UseOSCache"), true)
|
||||
|
@ -1310,6 +1311,8 @@ void Session::configure(libtorrent::settings_pack &settingsPack)
|
|||
settingsPack.set_bool(libt::settings_pack::announce_to_all_trackers, announceToAllTrackers());
|
||||
settingsPack.set_bool(libt::settings_pack::announce_to_all_tiers, announceToAllTiers());
|
||||
|
||||
settingsPack.set_int(libt::settings_pack::aio_threads, asyncIOThreads());
|
||||
|
||||
const int cacheSize = (diskCacheSize() > -1) ? (diskCacheSize() * 64) : -1;
|
||||
settingsPack.set_int(libt::settings_pack::cache_size, cacheSize);
|
||||
settingsPack.set_int(libt::settings_pack::cache_expiry, diskCacheTTL());
|
||||
|
@ -3028,6 +3031,20 @@ void Session::setAnnounceToAllTiers(bool val)
|
|||
}
|
||||
}
|
||||
|
||||
int Session::asyncIOThreads() const
|
||||
{
|
||||
return qBound(1, m_asyncIOThreads.value(), 1024);
|
||||
}
|
||||
|
||||
void Session::setAsyncIOThreads(const int num)
|
||||
{
|
||||
if (num == m_asyncIOThreads)
|
||||
return;
|
||||
|
||||
m_asyncIOThreads = num;
|
||||
configureDeferred();
|
||||
}
|
||||
|
||||
int Session::diskCacheSize() const
|
||||
{
|
||||
int size = m_diskCacheSize;
|
||||
|
|
|
@ -375,6 +375,8 @@ namespace BitTorrent
|
|||
void setAnnounceToAllTrackers(bool val);
|
||||
bool announceToAllTiers() const;
|
||||
void setAnnounceToAllTiers(bool val);
|
||||
int asyncIOThreads() const;
|
||||
void setAsyncIOThreads(int num);
|
||||
int diskCacheSize() const;
|
||||
void setDiskCacheSize(int size);
|
||||
int diskCacheTTL() const;
|
||||
|
@ -651,6 +653,7 @@ namespace BitTorrent
|
|||
CachedSettingValue<QString> m_IPFilterFile;
|
||||
CachedSettingValue<bool> m_announceToAllTrackers;
|
||||
CachedSettingValue<bool> m_announceToAllTiers;
|
||||
CachedSettingValue<int> m_asyncIOThreads;
|
||||
CachedSettingValue<int> m_diskCacheSize;
|
||||
CachedSettingValue<int> m_diskCacheTTL;
|
||||
CachedSettingValue<bool> m_useOSCache;
|
||||
|
|
|
@ -79,6 +79,9 @@ enum AdvSettingsRows
|
|||
|
||||
// libtorrent section
|
||||
LIBTORRENT_HEADER,
|
||||
#if LIBTORRENT_VERSION_NUM >= 10100
|
||||
ASYNC_IO_THREADS,
|
||||
#endif
|
||||
// cache
|
||||
DISK_CACHE,
|
||||
DISK_CACHE_TTL,
|
||||
|
@ -144,6 +147,10 @@ void AdvancedSettings::saveAdvancedSettings()
|
|||
Preferences *const pref = Preferences::instance();
|
||||
BitTorrent::Session *const session = BitTorrent::Session::instance();
|
||||
|
||||
#if LIBTORRENT_VERSION_NUM >= 10100
|
||||
// Async IO threads
|
||||
session->setAsyncIOThreads(spinBoxAsyncIOThreads.value());
|
||||
#endif
|
||||
// Disk write cache
|
||||
session->setDiskCacheSize(spinBoxCache.value());
|
||||
session->setDiskCacheTTL(spinBoxCacheTTL.value());
|
||||
|
@ -308,6 +315,14 @@ void AdvancedSettings::loadAdvancedSettings()
|
|||
item(LIBTORRENT_HEADER, PROPERTY)->setFont(boldFont);
|
||||
labelLibtorrentLink.setText(QString("<a href=\"%1\">%2</a>").arg("https://www.libtorrent.org/reference.html", tr("Open documentation")));
|
||||
labelLibtorrentLink.setOpenExternalLinks(true);
|
||||
|
||||
#if LIBTORRENT_VERSION_NUM >= 10100
|
||||
// Async IO threads
|
||||
spinBoxAsyncIOThreads.setMinimum(1);
|
||||
spinBoxAsyncIOThreads.setMaximum(1024);
|
||||
spinBoxAsyncIOThreads.setValue(session->asyncIOThreads());
|
||||
addRow(ASYNC_IO_THREADS, tr("Asynchronous I/O threads"), &spinBoxAsyncIOThreads);
|
||||
#endif
|
||||
// Disk write cache
|
||||
spinBoxCache.setMinimum(-1);
|
||||
// When build as 32bit binary, set the maximum at less than 2GB to prevent crashes.
|
||||
|
|
|
@ -59,7 +59,7 @@ private:
|
|||
template <typename T> void addRow(int row, const QString &rowText, T *widget);
|
||||
|
||||
QLabel labelQbtLink, labelLibtorrentLink;
|
||||
QSpinBox spinBoxCache, spinBoxSaveResumeDataInterval, spinBoxOutgoingPortsMin, spinBoxOutgoingPortsMax, spinBoxListRefresh, spinBoxMaxHalfOpen,
|
||||
QSpinBox spinBoxAsyncIOThreads, spinBoxCache, spinBoxSaveResumeDataInterval, spinBoxOutgoingPortsMin, spinBoxOutgoingPortsMax, spinBoxListRefresh, spinBoxMaxHalfOpen,
|
||||
spinBoxTrackerPort, spinBoxCacheTTL, spinBoxSendBufferWatermark, spinBoxSendBufferLowWatermark,
|
||||
spinBoxSendBufferWatermarkFactor, spinBoxSavePathHistoryLength;
|
||||
QCheckBox checkBoxOsCache, checkBoxRecheckCompleted, checkBoxResolveCountries, checkBoxResolveHosts, checkBoxSuperSeeding,
|
||||
|
|
Loading…
Reference in a new issue