Refactor App to use unified AppChannels for events

App now receives an AppChannels struct; AppEvent enum removed.

Event handling, tick generation, and audio communication are now
performed through dedicated channels.
This commit is contained in:
2026-05-03 22:27:08 +02:00
parent 7fb001faab
commit 7541db79d8
9 changed files with 123 additions and 105 deletions
+11 -14
View File
@@ -1,22 +1,19 @@
use crate::app::threads::AppEvent;
use std::{
sync::mpsc::Sender,
thread,
time::{Duration, Instant},
};
pub fn spawn_tick_thread(tx: Sender<AppEvent>, interval_ms: u64) {
thread::spawn(move || {
let interval: Duration = Duration::from_millis(interval_ms);
loop {
if tx.send(AppEvent::Tick).is_err() {
break;
}
let elapsed: Duration = Instant::now().elapsed();
if interval > elapsed {
thread::sleep(interval - elapsed);
}
pub fn handle_tick_event(tx: Sender<()>, interval_ms: u8) {
let interval: Duration = Duration::from_millis(interval_ms as u64);
loop {
if tx.send(()).is_err() {
break;
}
});
let elapsed: Duration = Instant::now().elapsed();
if interval > elapsed {
thread::sleep(interval - elapsed);
}
}
}