Browse Source

Add async io threads option to AdvancedSettings

adaptive-webui-19844
tjjh89017 7 years ago committed by Chocobo1
parent
commit
670a8e27af
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  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)
, m_IPFilterFile(BITTORRENT_SESSION_KEY("IPFilter")) , m_IPFilterFile(BITTORRENT_SESSION_KEY("IPFilter"))
, m_announceToAllTrackers(BITTORRENT_SESSION_KEY("AnnounceToAllTrackers"), false) , m_announceToAllTrackers(BITTORRENT_SESSION_KEY("AnnounceToAllTrackers"), false)
, m_announceToAllTiers(BITTORRENT_SESSION_KEY("AnnounceToAllTiers"), true) , m_announceToAllTiers(BITTORRENT_SESSION_KEY("AnnounceToAllTiers"), true)
, m_asyncIOThreads(BITTORRENT_SESSION_KEY("AsyncIOThreadsCount"), 4)
, m_diskCacheSize(BITTORRENT_SESSION_KEY("DiskCacheSize"), 64) , m_diskCacheSize(BITTORRENT_SESSION_KEY("DiskCacheSize"), 64)
, m_diskCacheTTL(BITTORRENT_SESSION_KEY("DiskCacheTTL"), 60) , m_diskCacheTTL(BITTORRENT_SESSION_KEY("DiskCacheTTL"), 60)
, m_useOSCache(BITTORRENT_SESSION_KEY("UseOSCache"), true) , 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_trackers, announceToAllTrackers());
settingsPack.set_bool(libt::settings_pack::announce_to_all_tiers, announceToAllTiers()); 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; const int cacheSize = (diskCacheSize() > -1) ? (diskCacheSize() * 64) : -1;
settingsPack.set_int(libt::settings_pack::cache_size, cacheSize); settingsPack.set_int(libt::settings_pack::cache_size, cacheSize);
settingsPack.set_int(libt::settings_pack::cache_expiry, diskCacheTTL()); 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 Session::diskCacheSize() const
{ {
int size = m_diskCacheSize; int size = m_diskCacheSize;

3
src/base/bittorrent/session.h

@ -375,6 +375,8 @@ namespace BitTorrent
void setAnnounceToAllTrackers(bool val); void setAnnounceToAllTrackers(bool val);
bool announceToAllTiers() const; bool announceToAllTiers() const;
void setAnnounceToAllTiers(bool val); void setAnnounceToAllTiers(bool val);
int asyncIOThreads() const;
void setAsyncIOThreads(int num);
int diskCacheSize() const; int diskCacheSize() const;
void setDiskCacheSize(int size); void setDiskCacheSize(int size);
int diskCacheTTL() const; int diskCacheTTL() const;
@ -651,6 +653,7 @@ namespace BitTorrent
CachedSettingValue<QString> m_IPFilterFile; CachedSettingValue<QString> m_IPFilterFile;
CachedSettingValue<bool> m_announceToAllTrackers; CachedSettingValue<bool> m_announceToAllTrackers;
CachedSettingValue<bool> m_announceToAllTiers; CachedSettingValue<bool> m_announceToAllTiers;
CachedSettingValue<int> m_asyncIOThreads;
CachedSettingValue<int> m_diskCacheSize; CachedSettingValue<int> m_diskCacheSize;
CachedSettingValue<int> m_diskCacheTTL; CachedSettingValue<int> m_diskCacheTTL;
CachedSettingValue<bool> m_useOSCache; CachedSettingValue<bool> m_useOSCache;

15
src/gui/advancedsettings.cpp

@ -79,6 +79,9 @@ enum AdvSettingsRows
// libtorrent section // libtorrent section
LIBTORRENT_HEADER, LIBTORRENT_HEADER,
#if LIBTORRENT_VERSION_NUM >= 10100
ASYNC_IO_THREADS,
#endif
// cache // cache
DISK_CACHE, DISK_CACHE,
DISK_CACHE_TTL, DISK_CACHE_TTL,
@ -144,6 +147,10 @@ void AdvancedSettings::saveAdvancedSettings()
Preferences *const pref = Preferences::instance(); Preferences *const pref = Preferences::instance();
BitTorrent::Session *const session = BitTorrent::Session::instance(); BitTorrent::Session *const session = BitTorrent::Session::instance();
#if LIBTORRENT_VERSION_NUM >= 10100
// Async IO threads
session->setAsyncIOThreads(spinBoxAsyncIOThreads.value());
#endif
// Disk write cache // Disk write cache
session->setDiskCacheSize(spinBoxCache.value()); session->setDiskCacheSize(spinBoxCache.value());
session->setDiskCacheTTL(spinBoxCacheTTL.value()); session->setDiskCacheTTL(spinBoxCacheTTL.value());
@ -308,6 +315,14 @@ void AdvancedSettings::loadAdvancedSettings()
item(LIBTORRENT_HEADER, PROPERTY)->setFont(boldFont); 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.setText(QString("<a href=\"%1\">%2</a>").arg("https://www.libtorrent.org/reference.html", tr("Open documentation")));
labelLibtorrentLink.setOpenExternalLinks(true); 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 // Disk write cache
spinBoxCache.setMinimum(-1); spinBoxCache.setMinimum(-1);
// When build as 32bit binary, set the maximum at less than 2GB to prevent crashes. // 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:
template <typename T> void addRow(int row, const QString &rowText, T *widget); template <typename T> void addRow(int row, const QString &rowText, T *widget);
QLabel labelQbtLink, labelLibtorrentLink; QLabel labelQbtLink, labelLibtorrentLink;
QSpinBox spinBoxCache, spinBoxSaveResumeDataInterval, spinBoxOutgoingPortsMin, spinBoxOutgoingPortsMax, spinBoxListRefresh, spinBoxMaxHalfOpen, QSpinBox spinBoxAsyncIOThreads, spinBoxCache, spinBoxSaveResumeDataInterval, spinBoxOutgoingPortsMin, spinBoxOutgoingPortsMax, spinBoxListRefresh, spinBoxMaxHalfOpen,
spinBoxTrackerPort, spinBoxCacheTTL, spinBoxSendBufferWatermark, spinBoxSendBufferLowWatermark, spinBoxTrackerPort, spinBoxCacheTTL, spinBoxSendBufferWatermark, spinBoxSendBufferLowWatermark,
spinBoxSendBufferWatermarkFactor, spinBoxSavePathHistoryLength; spinBoxSendBufferWatermarkFactor, spinBoxSavePathHistoryLength;
QCheckBox checkBoxOsCache, checkBoxRecheckCompleted, checkBoxResolveCountries, checkBoxResolveHosts, checkBoxSuperSeeding, QCheckBox checkBoxOsCache, checkBoxRecheckCompleted, checkBoxResolveCountries, checkBoxResolveHosts, checkBoxSuperSeeding,

Loading…
Cancel
Save