mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-21 07:57:22 -06:00
Allow to use POSIX-compliant disk IO type
This patch allows user to switch disk IO type between memory mapped files based type (default in libtorrent 2, and seems causing memory issues) and POSIX-compliant type which is more conservative on memory usage. Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com> Co-authored-by: Vladimir Golovnev (Glassez) <glassez@yandex.ru> PR #16895.
This commit is contained in:
@@ -34,6 +34,8 @@
|
||||
#include "common.h"
|
||||
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
#include <libtorrent/mmap_disk_io.hpp>
|
||||
#include <libtorrent/posix_disk_io.hpp>
|
||||
#include <libtorrent/session.hpp>
|
||||
|
||||
std::unique_ptr<lt::disk_interface> customDiskIOConstructor(
|
||||
@@ -42,6 +44,18 @@ std::unique_ptr<lt::disk_interface> customDiskIOConstructor(
|
||||
return std::make_unique<CustomDiskIOThread>(lt::default_disk_io_constructor(ioContext, settings, counters));
|
||||
}
|
||||
|
||||
std::unique_ptr<lt::disk_interface> customPosixDiskIOConstructor(
|
||||
lt::io_context &ioContext, const lt::settings_interface &settings, lt::counters &counters)
|
||||
{
|
||||
return std::make_unique<CustomDiskIOThread>(lt::posix_disk_io_constructor(ioContext, settings, counters));
|
||||
}
|
||||
|
||||
std::unique_ptr<lt::disk_interface> customMMapDiskIOConstructor(
|
||||
lt::io_context &ioContext, const lt::settings_interface &settings, lt::counters &counters)
|
||||
{
|
||||
return std::make_unique<CustomDiskIOThread>(lt::mmap_disk_io_constructor(ioContext, settings, counters));
|
||||
}
|
||||
|
||||
CustomDiskIOThread::CustomDiskIOThread(std::unique_ptr<libtorrent::disk_interface> nativeDiskIOThread)
|
||||
: m_nativeDiskIO {std::move(nativeDiskIOThread)}
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user