refactor: extract mod exit, task; Thread -> Task

This commit is contained in:
same mf who else 2026-03-28 14:11:23 +02:00
parent bea88ac58d
commit dae4d5a140
8 changed files with 114 additions and 74 deletions

View file

@ -1,4 +1,4 @@
use crate::play::Thread;
use crate::task::Task;
use ::std::sync::{Arc, RwLock, atomic::{AtomicBool, Ordering::*}};
use ::std::time::Duration;
@ -10,10 +10,10 @@ use ::crossterm::event::{
/// Spawn the TUI input thread which reads keys from the terminal.
pub fn tui_input <T: Do<TuiEvent, Usually<T>> + Send + Sync + 'static> (
exited: &Arc<AtomicBool>, state: &Arc<RwLock<T>>, poll: Duration
) -> Result<Thread, std::io::Error> {
) -> Result<Task, std::io::Error> {
let exited = exited.clone();
let state = state.clone();
Thread::new_poll(exited.clone(), poll, move |_| {
Task::new_poll(exited.clone(), poll, move |_| {
let event = read().unwrap();
match event {