From 1cc0e910b4e684e30326772a80c0c120aeba1c34 Mon Sep 17 00:00:00 2001 From: Clement Tsang <34804052+ClementTsang@users.noreply.github.com> Date: Thu, 8 Jun 2023 02:48:29 -0400 Subject: [PATCH] refactor: remove outdated collection thread code (#1190) This was going to be used for in-app config, but it's so old that it's probably better to just rip it out and start anew in that regard. --- src/lib.rs | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1713c0f7..4805e41b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -89,10 +89,8 @@ pub enum BottomEvent { /// Events sent to the collection thread. #[derive(Debug)] -pub enum ThreadEvent { +pub enum CollectionThreadEvent { Reset, - UpdateConfig(Box), - UpdateUsedWidgets(Box), } pub fn handle_mouse_event(event: MouseEvent, app: &mut App) { @@ -117,7 +115,7 @@ pub fn handle_mouse_event(event: MouseEvent, app: &mut App) { } pub fn handle_key_event_or_break( - event: KeyEvent, app: &mut App, reset_sender: &Sender, + event: KeyEvent, app: &mut App, reset_sender: &Sender, ) -> bool { // debug!("KeyEvent: {:?}", event); @@ -174,7 +172,7 @@ pub fn handle_key_event_or_break( KeyCode::Up => app.move_widget_selection(&WidgetDirection::Up), KeyCode::Down => app.move_widget_selection(&WidgetDirection::Down), KeyCode::Char('r') => { - if reset_sender.send(ThreadEvent::Reset).is_ok() { + if reset_sender.send(CollectionThreadEvent::Reset).is_ok() { app.reset(); } } @@ -487,7 +485,7 @@ pub fn create_input_thread( } pub fn create_collection_thread( - sender: Sender, control_receiver: Receiver, + sender: Sender, control_receiver: Receiver, termination_lock: Arc>, termination_cvar: Arc, app_config_fields: &AppConfigFields, filters: DataFilters, used_widget_set: UsedWidgets, ) -> JoinHandle<()> { @@ -520,19 +518,9 @@ pub fn create_collection_thread( if let Ok(message) = control_receiver.try_recv() { // trace!("Received message in collection thread: {:?}", message); match message { - ThreadEvent::Reset => { + CollectionThreadEvent::Reset => { data_state.data.cleanup(); } - ThreadEvent::UpdateConfig(app_config_fields) => { - data_state.set_temperature_type(app_config_fields.temperature_type); - data_state - .set_use_current_cpu_total(app_config_fields.use_current_cpu_total); - data_state.set_unnormalized_cpu(unnormalized_cpu); - data_state.set_show_average_cpu(app_config_fields.show_average_cpu); - } - ThreadEvent::UpdateUsedWidgets(used_widget_set) => { - data_state.set_data_collection(*used_widget_set); - } } }