mirror of
https://github.com/gopher64/gopher64.git
synced 2026-07-11 01:25:20 +02:00
make usb handle same as discord (#969)
This commit is contained in:
+2
-3
@@ -243,9 +243,8 @@ pub async fn run(args: Args, arg_count: usize) -> std::io::Result<()> {
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(shutdown_tx) = &shutdown_tx {
|
||||
ui::usb::close(shutdown_tx, usb_handle).await;
|
||||
}
|
||||
|
||||
ui::usb::close(shutdown_tx, usb_handle).await;
|
||||
} else if arg_count > 1 {
|
||||
let mut config = ui::config::Config::new();
|
||||
|
||||
|
||||
+8
-5
@@ -175,16 +175,19 @@ pub fn init() -> (
|
||||
}
|
||||
|
||||
pub async fn close(
|
||||
shutdown_tx: &tokio::sync::watch::Sender<()>,
|
||||
shutdown_tx: Option<tokio::sync::watch::Sender<()>>,
|
||||
usb_handle: Option<tokio::task::JoinHandle<()>>,
|
||||
) {
|
||||
let _ = shutdown_tx.send(());
|
||||
if let Some(mut handle) = usb_handle
|
||||
&& tokio::time::timeout(std::time::Duration::from_secs(1), &mut handle)
|
||||
&& let Some(shutdown_tx) = shutdown_tx
|
||||
{
|
||||
let _ = shutdown_tx.send(());
|
||||
if tokio::time::timeout(std::time::Duration::from_secs(1), &mut handle)
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
handle.abort();
|
||||
{
|
||||
handle.abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user