code cleanup

This commit is contained in:
Nickiel12 2024-04-06 11:05:18 -07:00
parent cf094dd746
commit 848bdca4ac
2 changed files with 5 additions and 7 deletions

View file

@ -60,7 +60,7 @@ impl <'a> CoordState<'a> {
} }
pub async fn socket_start(&mut self, conn: String) { pub async fn socket_start(&mut self, conn: String) {
if !(self.sck_recv_alive.load(Ordering::SeqCst) && !self.sck_send_alive.load(Ordering::SeqCst)) { if !(self.sck_recv_alive.load(Ordering::SeqCst) && self.sck_send_alive.load(Ordering::SeqCst)) {
info!("Starting socket"); info!("Starting socket");
let (to_socket, socket_sender_rx) = async_channel::bounded::<Message>(10); let (to_socket, socket_sender_rx) = async_channel::bounded::<Message>(10);
@ -89,13 +89,11 @@ impl <'a> CoordState<'a> {
if let Err(e) = self.to_gui.send(GuiUpdate::SocketState(false)).await { if let Err(e) = self.to_gui.send(GuiUpdate::SocketState(false)).await {
error!("Cannot send message to gui thread: {e}"); error!("Cannot send message to gui thread: {e}");
} }
} else { } else if let Err(e) = self.to_gui.send(GuiUpdate::SocketState(true)).await {
if let Err(e) = self.to_gui.send(GuiUpdate::SocketState(true)).await {
error!("Cannot send message to gui thread: {e}"); error!("Cannot send message to gui thread: {e}");
self.close().await; self.close().await;
} }
} }
}
pub async fn close(&mut self) { pub async fn close(&mut self) {
info!("closing coord state"); info!("closing coord state");

View file

@ -2,7 +2,7 @@ use crate::coordinator::{ApplicationEvent, MoveEvent};
use async_channel::Sender; use async_channel::Sender;
use gilrs::{ev::filter::FilterFn, Axis, Button, Event, EventType, Filter, Gilrs, GilrsBuilder}; use gilrs::{ev::filter::FilterFn, Axis, Button, Event, EventType, Filter, Gilrs, GilrsBuilder};
use log::{debug, info, warn}; use log::{info, warn};
use std::{ use std::{
panic::{self, AssertUnwindSafe}, panic::{self, AssertUnwindSafe},
sync::{atomic::AtomicBool, Arc}, sync::{atomic::AtomicBool, Arc},