mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-04-25 13:40:43 +02:00
refactor: extract mod exit, task; Thread -> Task
This commit is contained in:
parent
bea88ac58d
commit
dae4d5a140
8 changed files with 114 additions and 74 deletions
|
|
@ -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 {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue