merged disk buffer pool change from RC_0_16

This commit is contained in:
Arvid Norberg 2013-03-17 17:13:34 +00:00
parent 8d8d160b35
commit 56e4c48873
3 changed files with 4 additions and 30 deletions

View File

@ -17,6 +17,10 @@
* fix uTP edge case where udp socket buffer fills up
* fix nagle implementation in uTP
* don't use pool allocator for disk blocks (cache may now return pages to the kernel)
0.16.9 release
* fix long filename truncation on windows
* distinguish file open mode when checking files and downloading/seeding with bittorrent. updates storage interface
* improve file_storage::map_file when dealing with invalid input

View File

@ -38,10 +38,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/session_settings.hpp"
#include "libtorrent/allocator.hpp"
#ifndef TORRENT_DISABLE_POOL_ALLOCATOR
#include <boost/pool/pool.hpp>
#endif
#ifdef TORRENT_DISK_STATS
#include <fstream>
#endif
@ -101,12 +97,6 @@ namespace libtorrent
mutable mutex m_pool_mutex;
#ifndef TORRENT_DISABLE_POOL_ALLOCATOR
// memory pool for read and write operations
// and disk cache
boost::pool<page_aligned_allocator> m_pool;
#endif
#if defined TORRENT_DISK_STATS || defined TORRENT_STATS
int m_allocations;
#endif

View File

@ -47,9 +47,6 @@ namespace libtorrent
disk_buffer_pool::disk_buffer_pool(int block_size)
: m_block_size(block_size)
, m_in_use(0)
#ifndef TORRENT_DISABLE_POOL_ALLOCATOR
, m_pool(block_size, m_settings.cache_buffer_chunk_size)
#endif
{
#if defined TORRENT_DISK_STATS || defined TORRENT_STATS
m_allocations = 0;
@ -83,11 +80,7 @@ namespace libtorrent
if (m_buf_to_category.find(buffer)
== m_buf_to_category.end()) return false;
#endif
#ifdef TORRENT_DISABLE_POOL_ALLOCATOR
return true;
#else
return m_pool.is_from(buffer);
#endif
}
bool disk_buffer_pool::is_disk_buffer(char* buffer) const
@ -101,12 +94,7 @@ namespace libtorrent
{
mutex::scoped_lock l(m_pool_mutex);
TORRENT_ASSERT(m_magic == 0x1337);
#ifdef TORRENT_DISABLE_POOL_ALLOCATOR
char* ret = page_aligned_allocator::malloc(m_block_size);
#else
char* ret = (char*)m_pool.malloc();
m_pool.set_next_size(m_settings.cache_buffer_chunk_size);
#endif
++m_in_use;
#if TORRENT_USE_MLOCK
if (m_settings.lock_disk_cache)
@ -197,21 +185,13 @@ namespace libtorrent
#endif
}
#endif
#ifdef TORRENT_DISABLE_POOL_ALLOCATOR
page_aligned_allocator::free(buf);
#else
m_pool.free(buf);
#endif
--m_in_use;
}
void disk_buffer_pool::release_memory()
{
TORRENT_ASSERT(m_magic == 0x1337);
#ifndef TORRENT_DISABLE_POOL_ALLOCATOR
mutex::scoped_lock l(m_pool_mutex);
m_pool.release_memory();
#endif
}
}