void run_test(connections_t& v , bandwidth_manager& manager , boost::function<void()> f = &nop) { std::cerr << "-------------" << std::endl; std::for_each(v.begin(), v.end() , boost::bind(&peer_connection::start, _1)); for (int i = 0; i < int(sample_time * 10); ++i) { manager.update_quotas(milliseconds(100)); if ((i % 15) == 0) f(); } }
void do_change_peer_rate(connections_t& v, int limit) { static int count = 10; --count; if (count == 0) { std::for_each(v.begin(), v.end() , boost::bind(&peer_connection::throttle, _1, limit)); return; } int c = count; for (connections_t::iterator i = v.begin(); i != v.end(); ++i, ++c) i->get()->throttle(limit + limit / 2 * ((c & 1)?-1:1)); }
void spawn_connections(connections_t& v, bandwidth_manager<peer_connection>& bwm , bandwidth_channel& bwc, int num, char const* prefix) { for (int i = 0; i < num; ++i) { v.push_back(new peer_connection(bwm, bwc, 200, false , prefix + boost::lexical_cast<std::string>(i))); } }
void spawn_connections(connections_t& v, bandwidth_manager& bwm , bandwidth_channel& bwc, int num, char const* prefix) { for (int i = 0; i < num; ++i) { char name[200]; snprintf(name, sizeof(name), "%s%d", prefix, i); v.push_back(boost::shared_ptr<peer_connection>(new peer_connection(bwm, bwc, 200, false, name))); } }
void run_test(connections_t& v , bandwidth_manager& manager , boost::function<void()> f = &nop) { std::cerr << "-------------" << std::endl; std::for_each(v.begin(), v.end() , boost::bind(&peer_connection::start, _1)); libtorrent::aux::session_settings s; initialize_default_settings(s); int tick_interval = s.get_int(settings_pack::tick_interval); for (int i = 0; i < int(sample_time * 1000 / tick_interval); ++i) { manager.update_quotas(milliseconds(tick_interval)); if ((i % 15) == 0) f(); } }