pub async fn new() -> Self {
        let (tx, rx) = unbounded_channel::<DownloadRequest>();
        let cache = Self {
            data: Arc::new(Mutex::new(HashMap::new())),
            downloaders: Arc::new(Mutex::new(HashMap::new())),
            cv: Arc::new(std::sync::Condvar::new()),
            tx,
            stats: Arc::new(RangeCacheStats {
                downloaded_bytes: AtomicUsize::new(0),
                processed_bytes: AtomicUsize::new(0),
                waiting_download_ms: AtomicUsize::new(0),
                download_count: AtomicUsize::new(0),
            }),
        };
        cache.start(rx).await;
        cache
    }
/// Spawns a task that will listen for new chunks to download and schedule them for download
Spawns a task that will listen for new chunks to download and schedule them for download
Spawns a task that will listen for new chunks to download and schedule them for download
pub async fn new() -> Self {
        let (tx, rx) = unbounded_channel::<DownloadRequest>();
        let cache = Self {
            data: Arc::new(Mutex::new(HashMap::new())),
            downloaders: Arc::new(Mutex::new(HashMap::new())),
            cv: Arc::new(std::sync::Condvar::new()),
            tx,
            stats: Arc::new(RangeCacheStats {
                downloaded_bytes: AtomicUsize::new(0),
                processed_bytes: AtomicUsize::new(0),
                waiting_download_ms: AtomicUsize::new(0),
                download_count: AtomicUsize::new(0),
            }),
        };
        cache.start(rx).await;
        cache
    }
pub async fn new ( ) -> Self { let ( tx , rx ) = unbounded_channel :: < DownloadRequest > ( ) ; let cache = Self { data : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) , downloaders : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) , cv : Arc :: new ( std :: sync :: Condvar :: new ( ) ) , tx , stats : Arc :: new ( RangeCacheStats { downloaded_bytes : AtomicUsize :: new ( 0 ) , processed_bytes : AtomicUsize :: new ( 0 ) , waiting_download_ms : AtomicUsize :: new ( 0 ) , download_count : AtomicUsize :: new ( 0 ) , } ) , } ; cache . start ( rx ) . await ; cache }
Spawns a task that will listen for new chunks to download and schedule them for download
Spawns a task that will listen for new chunks to download and schedule them for download