chore(exit): Progress on cleanup and exit

This commit is contained in:
quexeky
2025-01-16 17:51:30 +11:00
committed by quexeky
parent 9369ff14b8
commit 0381b8b8cb
3 changed files with 14 additions and 8 deletions

View File

@ -3,8 +3,7 @@ use std::{
collections::VecDeque,
fmt::Debug,
sync::{
mpsc::{SendError, Sender},
MutexGuard,
mpsc::{SendError, Sender}, Mutex, MutexGuard
},
thread::JoinHandle,
};
@ -84,7 +83,7 @@ pub enum DownloadStatus {
/// which provides raw access to the underlying queue.
/// THIS EDITING IS BLOCKING!!!
pub struct DownloadManager {
terminator: JoinHandle<Result<(), ()>>,
terminator: Mutex<JoinHandle<Result<(), ()>>>,
download_queue: Queue,
progress: CurrentProgressObject,
command_sender: Sender<DownloadManagerSignal>,
@ -174,7 +173,7 @@ impl DownloadManager {
pub fn resume_downloads(&self) {
self.command_sender.send(DownloadManagerSignal::Go).unwrap();
}
pub fn ensure_terminated(self) -> Result<Result<(), ()>, Box<dyn Any + Send>> {
pub fn ensure_terminated(&self) -> Result<Result<(), ()>, Box<dyn Any + Send>> {
self.command_sender
.send(DownloadManagerSignal::Finish)
.unwrap();