modernize session_view example to use c++11

This commit is contained in:
arvidn 2017-05-17 09:37:11 -04:00 committed by Arvid Norberg
parent 1925d1e7aa
commit a9044e4d97
2 changed files with 32 additions and 62 deletions

View File

@ -48,39 +48,6 @@ session_view::session_view()
std::vector<lt::stats_metric> metrics = lt::session_stats_metrics();
m_cnt[0].resize(metrics.size(), 0);
m_cnt[1].resize(metrics.size(), 0);
m_queued_bytes_idx = find_metric_idx("disk.queued_write_bytes");
m_wasted_bytes_idx = find_metric_idx("net.recv_redundant_bytes");
m_failed_bytes_idx = find_metric_idx("net.recv_failed_bytes");
m_num_peers_idx = find_metric_idx("peer.num_peers_connected");
m_recv_payload_idx = find_metric_idx("net.recv_payload_bytes");
m_sent_payload_idx = find_metric_idx("net.sent_payload_bytes");
m_unchoked_idx = find_metric_idx("peer.num_peers_up_unchoked");
m_unchoke_slots_idx = find_metric_idx("ses.num_unchoke_slots");
m_limiter_up_queue_idx = find_metric_idx("net.limiter_up_queue");
m_limiter_down_queue_idx = find_metric_idx("net.limiter_down_queue");
m_queued_writes_idx = find_metric_idx("disk.num_write_jobs");
m_queued_reads_idx = find_metric_idx("disk.num_read_jobs");
m_writes_cache_idx = find_metric_idx("disk.write_cache_blocks");
m_reads_cache_idx = find_metric_idx("disk.read_cache_blocks");
m_pinned_idx = find_metric_idx("disk.pinned_blocks");
m_num_blocks_read_idx = find_metric_idx("disk.num_blocks_read");
m_cache_hit_idx = find_metric_idx("disk.num_blocks_cache_hits");
m_blocks_in_use_idx = find_metric_idx("disk.disk_blocks_in_use");
m_blocks_written_idx = find_metric_idx("disk.num_blocks_written");
m_write_ops_idx = find_metric_idx("disk.num_write_ops");
m_mfu_size_idx = find_metric_idx("disk.arc_mfu_size");
m_mfu_ghost_idx = find_metric_idx("disk.arc_mfu_ghost_size");
m_mru_size_idx = find_metric_idx("disk.arc_mru_size");
m_mru_ghost_idx = find_metric_idx("disk.arc_mru_ghost_size");
m_utp_idle = find_metric_idx("utp.num_utp_idle");
m_utp_syn_sent = find_metric_idx("utp.num_utp_syn_sent");
m_utp_connected = find_metric_idx("utp.num_utp_connected");
m_utp_fin_sent = find_metric_idx("utp.num_utp_fin_sent");
m_utp_close_wait = find_metric_idx("utp.num_utp_close_wait");
}
void session_view::set_pos(int pos)

View File

@ -36,6 +36,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <cstdint>
#include <vector>
#include "libtorrent/session_stats.hpp"
struct session_view
{
session_view();
@ -69,37 +71,38 @@ private:
bool m_print_utp_stats;
int m_queued_bytes_idx;
int m_wasted_bytes_idx;
int m_failed_bytes_idx;
int m_num_peers_idx;
int m_recv_payload_idx;
int m_sent_payload_idx;
int m_unchoked_idx;
int m_unchoke_slots_idx;
int m_limiter_up_queue_idx;
int m_limiter_down_queue_idx;
int m_queued_writes_idx;
int m_queued_reads_idx;
int m_writes_cache_idx;
int m_reads_cache_idx;
int m_pinned_idx;
int m_num_blocks_read_idx;
int m_cache_hit_idx;
int m_blocks_in_use_idx;
int m_blocks_written_idx;
int m_write_ops_idx;
int const m_queued_bytes_idx = lt::find_metric_idx("disk.queued_write_bytes");
int const m_wasted_bytes_idx = lt::find_metric_idx("net.recv_redundant_bytes");
int const m_failed_bytes_idx = lt::find_metric_idx("net.recv_failed_bytes");
int const m_num_peers_idx = lt::find_metric_idx("peer.num_peers_connected");
int const m_recv_payload_idx = lt::find_metric_idx("net.recv_payload_bytes");
int const m_sent_payload_idx = lt::find_metric_idx("net.sent_payload_bytes");
int const m_unchoked_idx = lt::find_metric_idx("peer.num_peers_up_unchoked");
int const m_unchoke_slots_idx = lt::find_metric_idx("ses.num_unchoke_slots");
int const m_limiter_up_queue_idx = lt::find_metric_idx("net.limiter_up_queue");
int const m_limiter_down_queue_idx = lt::find_metric_idx("net.limiter_down_queue");
int const m_queued_writes_idx = lt::find_metric_idx("disk.num_write_jobs");
int const m_queued_reads_idx = lt::find_metric_idx("disk.num_read_jobs");
int m_mfu_size_idx;
int m_mfu_ghost_idx;
int m_mru_size_idx;
int m_mru_ghost_idx;
int const m_writes_cache_idx = lt::find_metric_idx("disk.write_cache_blocks");
int const m_reads_cache_idx = lt::find_metric_idx("disk.read_cache_blocks");
int const m_pinned_idx = lt::find_metric_idx("disk.pinned_blocks");
int const m_num_blocks_read_idx = lt::find_metric_idx("disk.num_blocks_read");
int const m_cache_hit_idx = lt::find_metric_idx("disk.num_blocks_cache_hits");
int const m_blocks_in_use_idx = lt::find_metric_idx("disk.disk_blocks_in_use");
int const m_blocks_written_idx = lt::find_metric_idx("disk.num_blocks_written");
int const m_write_ops_idx = lt::find_metric_idx("disk.num_write_ops");
int m_utp_idle;
int m_utp_syn_sent;
int m_utp_connected;
int m_utp_fin_sent;
int m_utp_close_wait;
int const m_mfu_size_idx = lt::find_metric_idx("disk.arc_mfu_size");
int const m_mfu_ghost_idx = lt::find_metric_idx("disk.arc_mfu_ghost_size");
int const m_mru_size_idx = lt::find_metric_idx("disk.arc_mru_size");
int const m_mru_ghost_idx = lt::find_metric_idx("disk.arc_mru_ghost_size");
int const m_utp_idle = lt::find_metric_idx("utp.num_utp_idle");
int const m_utp_syn_sent = lt::find_metric_idx("utp.num_utp_syn_sent");
int const m_utp_connected = lt::find_metric_idx("utp.num_utp_connected");
int const m_utp_fin_sent = lt::find_metric_idx("utp.num_utp_fin_sent");
int const m_utp_close_wait = lt::find_metric_idx("utp.num_utp_close_wait");
};
#endif