chore(downloads): Progress on write speeds & added debug statements

This commit is contained in:
Louis van Liefland
2024-11-23 23:32:56 +11:00
parent 76b0975bcc
commit b065e101e6
7 changed files with 67 additions and 17 deletions

View File

@ -1,12 +1,13 @@
use std::sync::{
use std::{sync::{
atomic::{AtomicUsize, Ordering},
Arc, Mutex,
};
}, time::Instant};
#[derive(Clone)]
pub struct ProgressObject {
max: Arc<Mutex<usize>>,
progress_instances: Arc<Mutex<Vec<Arc<AtomicUsize>>>>,
start: Arc<Mutex<Instant>>
}
impl ProgressObject {
@ -15,8 +16,12 @@ impl ProgressObject {
Self {
max: Arc::new(Mutex::new(max)),
progress_instances: Arc::new(arr),
start: Arc::new(Mutex::new(Instant::now())),
}
}
pub fn set_time_now(&self) {
*self.start.lock().unwrap() = Instant::now();
}
pub fn sum(&self) -> usize {
self.progress_instances
.lock()