deleting useless code

This commit is contained in:
ALEZ-DEV 2024-05-04 19:27:07 +02:00
parent cf05625135
commit 8bbbeb59c0

View File

@ -189,51 +189,3 @@ impl ComponentDownloader for GameComponent {
panic!("How did you run this function??!!")
}
}
struct FileDownloadReporterPrivate {
last_update: Instant,
max_progress: Option<u64>,
last_current_progress: u64,
}
struct FileDownloadReporter<P: Reporter> {
private: Mutex<Option<FileDownloadReporterPrivate>>,
progress: Mutex<Arc<P>>,
}
impl<P: Reporter> FileDownloadReporter<P> {
pub fn create(progress: Arc<P>) -> Arc<Self> {
Arc::new(Self {
private: Mutex::new(None),
progress: Mutex::new(progress),
})
}
}
impl<P: Reporter> Reporter for FileDownloadReporter<P> {
fn setup(&self, max_progress: Option<u64>, message: &str) {
let private = FileDownloadReporterPrivate {
last_update: Instant::now(),
max_progress,
last_current_progress: 0,
};
let mut guard = self.private.lock().unwrap();
*guard = Some(private);
}
fn progress(&self, current: u64) {
if let Some(private) = self.private.lock().unwrap().as_mut() {
let progress = self.progress.lock().unwrap();
if private.last_update.elapsed().as_millis() >= 250 {
progress.progress(current - private.last_current_progress); // to add to the progress
private.last_current_progress = current;
}
private.last_update = Instant::now();
}
}
fn set_message(&self, message: &str) {}
fn done(&self) {}
}