aquatic: add and use Config.poll_event_capacity

This commit is contained in:
Joakim Frostegård 2020-04-07 13:50:10 +02:00
parent f5700bfa18
commit 74e3a51fbe
3 changed files with 3 additions and 2 deletions

View file

@ -9,7 +9,6 @@ use indexmap::IndexMap;
pub use bittorrent_udp::types::*;
pub const EVENT_CAPACITY: usize = 4096;
pub const MAX_PACKET_SIZE: usize = 4096;

View file

@ -6,6 +6,7 @@ pub struct Config {
pub address: SocketAddr,
pub num_threads: usize,
pub recv_buffer_size: usize,
pub poll_event_capacity: usize,
pub max_scrape_torrents: u8,
pub max_response_peers: usize,
pub statistics_interval: u64,
@ -17,6 +18,7 @@ impl Default for Config {
Self {
address: SocketAddr::from(([127, 0, 0, 1], 3000)),
num_threads: 4,
poll_event_capacity: 4096,
recv_buffer_size: 4096 * 16,
max_scrape_torrents: 255,
max_response_peers: 255,

View file

@ -62,7 +62,7 @@ pub fn run_event_loop(
.register(&mut socket, Token(token_num), interests)
.unwrap();
let mut events = Events::with_capacity(EVENT_CAPACITY);
let mut events = Events::with_capacity(config.poll_event_capacity);
let mut connect_requests: Vec<(ConnectRequest, SocketAddr)> = Vec::with_capacity(1024);
let mut announce_requests: Vec<(AnnounceRequest, SocketAddr)> = Vec::with_capacity(1024);