Browse Source

Merge pull request #9109 from tjjh89017/master

Add aio_threads option to AdvanceSetting Page
adaptive-webui-19844
Mike Tzou 6 years ago committed by GitHub
parent
commit
c81756111c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      src/base/bittorrent/session.cpp
  2. 3
      src/base/bittorrent/session.h
  3. 15
      src/gui/advancedsettings.cpp
  4. 2
      src/gui/advancedsettings.h

17
src/base/bittorrent/session.cpp

@ -274,6 +274,7 @@ Session::Session(QObject *parent) @@ -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) @@ -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) @@ -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;

3
src/base/bittorrent/session.h

@ -375,6 +375,8 @@ namespace BitTorrent @@ -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 @@ -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;

15
src/gui/advancedsettings.cpp

@ -79,6 +79,9 @@ enum AdvSettingsRows @@ -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() @@ -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() @@ -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.

2
src/gui/advancedsettings.h

@ -59,7 +59,7 @@ private: @@ -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…
Cancel
Save