duplicate loop

This commit is contained in:
🪞👃🪞 2024-07-05 11:07:50 +03:00
parent 768c2337e7
commit 2e26fc2eaa
5 changed files with 141 additions and 29 deletions

View file

@ -1,19 +1,22 @@
// Stdlib dependencies:
pub use std::error::Error;
pub use std::io::{stdout, Stdout, Write};
pub use std::thread::{spawn, JoinHandle};
pub use std::time::Duration;
pub use std::collections::BTreeMap;
pub use std::sync::{Arc, Mutex, MutexGuard};
pub use std::sync::atomic::{Ordering, AtomicBool, AtomicUsize};
pub use std::sync::mpsc::{channel, Sender, Receiver};
pub(crate) use std::error::Error;
pub(crate) use std::io::{stdout};
pub(crate) use std::thread::{spawn, JoinHandle};
pub(crate) use std::time::Duration;
pub(crate) use std::collections::BTreeMap;
pub(crate) use std::sync::atomic::{Ordering, AtomicBool, AtomicUsize};
pub(crate) use std::sync::{
Arc,
Mutex, MutexGuard,
RwLock, LockResult, TryLockResult, RwLockReadGuard, RwLockWriteGuard
};
// Non-stdlib dependencies:
pub use microxdg::XdgApp;
pub use ratatui::prelude::*;
pub use midly::{MidiMessage, live::LiveEvent, num::u7};
pub use crossterm::{ExecutableCommand, QueueableCommand};
pub use crossterm::event::{Event, KeyEvent, KeyCode, KeyModifiers};
pub(crate) use microxdg::XdgApp;
pub(crate) use ratatui::prelude::*;
pub(crate) use midly::{MidiMessage, live::LiveEvent, num::u7};
pub(crate) use crossterm::{ExecutableCommand};
pub(crate) use crossterm::event::{Event, KeyEvent, KeyCode, KeyModifiers};
use better_panic::{Settings, Verbosity};
use crossterm::terminal::{
EnterAlternateScreen, LeaveAlternateScreen,
@ -108,7 +111,7 @@ pub fn main_thread (
let exited = exited.clone();
let device = device.clone();
let mut terminal = ratatui::Terminal::new(CrosstermBackend::new(stdout()))?;
let sleep = std::time::Duration::from_millis(16);
let sleep = Duration::from_millis(16);
Ok(spawn(move || loop {
terminal.draw(|frame|{
@ -133,7 +136,7 @@ pub fn input_thread (
exited: &Arc<AtomicBool>,
device: &Arc<Mutex<impl Handle + Send + 'static>>
) -> JoinHandle<()> {
let poll = std::time::Duration::from_millis(100);
let poll = Duration::from_millis(100);
let exited = exited.clone();
let device = device.clone();
spawn(move || loop {