Files
war-in-tunnels/src/app/threads/tick.rs
T
GarandPLG 7541db79d8 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.
2026-05-03 22:27:08 +02:00

20 lines
444 B
Rust

use std::{
sync::mpsc::Sender,
thread,
time::{Duration, Instant},
};
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);
}
}
}