WIP: use shared swarm state in mio worker

This commit is contained in:
Joakim Frostegård 2024-02-10 11:21:48 +01:00
parent 53497308f1
commit 2da966098f
5 changed files with 79 additions and 255 deletions

View file

@ -13,6 +13,7 @@ use crossbeam_utils::CachePadded;
use hdrhistogram::Histogram;
use crate::config::Config;
use crate::swarm::TorrentMaps;
pub const BUFFER_SIZE: usize = 8192;
@ -230,13 +231,15 @@ pub enum StatisticsMessage {
#[derive(Clone)]
pub struct State {
pub access_list: Arc<AccessListArcSwap>,
pub torrent_maps: TorrentMaps,
pub server_start_instant: ServerStartInstant,
}
impl Default for State {
fn default() -> Self {
impl State {
pub fn new(config: &Config) -> Self {
Self {
access_list: Arc::new(AccessListArcSwap::default()),
torrent_maps: TorrentMaps::new(config),
server_start_instant: ServerStartInstant::new(),
}
}