From 23a7e8d40a734fd4e1755224a98354822848bbd8 Mon Sep 17 00:00:00 2001 From: arvidn Date: Thu, 29 Dec 2016 14:54:16 -0800 Subject: [PATCH] hide the block_cache_reference from disk_buffer_holder --- include/libtorrent/disk_buffer_holder.hpp | 3 ++- include/libtorrent/disk_io_thread.hpp | 2 -- src/bt_peer_connection.cpp | 2 +- src/disk_io_thread.cpp | 1 - 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/include/libtorrent/disk_buffer_holder.hpp b/include/libtorrent/disk_buffer_holder.hpp index d4c4c0792..59421b722 100644 --- a/include/libtorrent/disk_buffer_holder.hpp +++ b/include/libtorrent/disk_buffer_holder.hpp @@ -102,7 +102,8 @@ namespace libtorrent std::swap(h.m_ref, m_ref); } - aux::block_cache_reference ref() const noexcept { return m_ref; } + // if this returns true, the buffer may not be modified in place + bool is_mutable() const noexcept { return m_ref.storage == nullptr; } // implicitly convertible to true if the object is currently holding a // buffer diff --git a/include/libtorrent/disk_io_thread.hpp b/include/libtorrent/disk_io_thread.hpp index b8828603a..baf962bc5 100644 --- a/include/libtorrent/disk_io_thread.hpp +++ b/include/libtorrent/disk_io_thread.hpp @@ -521,8 +521,6 @@ namespace libtorrent // the last time we expired write blocks from the cache time_point m_last_cache_expiry = min_time(); - time_point m_last_file_check; - // LRU cache of open files file_pool m_file_pool{40}; diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 65b151c36..a2039f383 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -2463,7 +2463,7 @@ namespace libtorrent send_buffer(msg, 13); } - if (buffer.ref().storage == nullptr) + if (buffer.is_mutable()) { append_send_buffer(std::move(buffer), r.length); } diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 37a19a4d0..e4d915e9b 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -194,7 +194,6 @@ namespace libtorrent , m_generic_threads(m_generic_io_jobs, ios) , m_hash_io_jobs(*this, thread_type_t::hasher) , m_hash_threads(m_hash_io_jobs, ios) - , m_last_file_check(clock_type::now()) , m_disk_cache(block_size, ios, std::bind(&disk_io_thread::trigger_cache_trim, this)) , m_stats_counters(cnt) , m_ios(ios)