mirror of
https://github.com/ALEZ-DEV/Babylonia-terminal.git
synced 2026-03-21 21:58:52 +00:00
deleting useless code
This commit is contained in:
parent
cf05625135
commit
8bbbeb59c0
@ -189,51 +189,3 @@ impl ComponentDownloader for GameComponent {
|
|||||||
panic!("How did you run this function??!!")
|
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) {}
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user