move stats instrumentation to .cpp file to fix header dependency issue

This commit is contained in:
Arvid Norberg 2009-10-28 19:56:18 +00:00
parent 70df388e6c
commit dcd8bb6718
3 changed files with 21 additions and 7 deletions

View File

@ -83,6 +83,10 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket_io.hpp" // for print_address
#include "libtorrent/peer_connection.hpp" // for intrusive_ptr_release
#ifdef TORRENT_STATS
#include <fstream>
#endif
namespace libtorrent
{

View File

@ -483,18 +483,17 @@ namespace libtorrent
virtual buffer::interval allocate_send_buffer(int size);
virtual void setup_send();
#if TORRENT_STATS
void log_buffer_usage(char* buffer, int size, char const* label);
#endif
template <class Destructor>
void append_send_buffer(char* buffer, int size, Destructor const& destructor)
{
#if TORRENT_DISK_STATS
if (m_ses.m_disk_thread.is_disk_buffer(buffer))
m_ses.m_disk_thread.rename_buffer(buffer, "queued send buffer");
#if TORRENT_STATS
log_buffer_usage(buffer, size, "queued send buffer");
#endif
m_send_buffer.append_buffer(buffer, size, size, destructor);
#ifdef TORRENT_STATS
m_ses.m_buffer_usage_logger << log_time() << " append_send_buffer: " << size << std::endl;
m_ses.log_buffer_usage();
#endif
}
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES

View File

@ -325,6 +325,17 @@ namespace libtorrent
std::fill(m_peer_id.begin(), m_peer_id.end(), 0);
}
#if TORRENT_STATS
void peer_connection::log_buffer_usage(char* buffer, int size, char const* label)
{
if (m_ses.m_disk_thread.is_disk_buffer(buffer))
m_ses.m_disk_thread.rename_buffer(buffer, label);
m_ses.m_buffer_usage_logger << log_time() << " append_send_buffer: " << size << std::endl;
m_ses.log_buffer_usage();
}
#endif
bool peer_connection::unchoke_compare(boost::intrusive_ptr<peer_connection const> const& p) const
{
TORRENT_ASSERT(p);