tiny tidy
This commit is contained in:
parent
75677faeae
commit
3e112d1cb6
2 changed files with 27 additions and 25 deletions
|
@ -45,7 +45,7 @@ impl App {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
pub async fn run(
|
pub async fn start_and_run(
|
||||||
&mut self,
|
&mut self,
|
||||||
terminal: &mut DefaultTerminal,
|
terminal: &mut DefaultTerminal,
|
||||||
config: Config,
|
config: Config,
|
||||||
|
@ -141,29 +141,6 @@ impl App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn shutdown(handles: &mut JoinSet<Listeners>) {
|
|
||||||
let mut alarm = tokio::time::interval(tokio::time::Duration::from_secs(5));
|
|
||||||
alarm.tick().await;
|
|
||||||
loop {
|
|
||||||
tokio::select! {
|
|
||||||
join_result = handles.join_next() => {
|
|
||||||
match join_result {
|
|
||||||
Some(handle) => match handle {
|
|
||||||
Ok(h) => println!("Stopped {h:?}"),
|
|
||||||
Err(e) => println!("Got error {e:?}"),
|
|
||||||
}
|
|
||||||
None => break,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ = alarm.tick() => {
|
|
||||||
println!("Exit timeout reached, aborting all unjoined tasks");
|
|
||||||
handles.abort_all();
|
|
||||||
break;
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Widget for &App {
|
impl Widget for &App {
|
||||||
fn render(self, area: Rect, buf: &mut Buffer) {
|
fn render(self, area: Rect, buf: &mut Buffer) {
|
||||||
let title = Line::from(" Joecalsend ".bold());
|
let title = Line::from(" Joecalsend ".bold());
|
||||||
|
@ -194,3 +171,26 @@ impl Widget for &App {
|
||||||
.render(area, buf);
|
.render(area, buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn shutdown(handles: &mut JoinSet<Listeners>) {
|
||||||
|
let mut alarm = tokio::time::interval(tokio::time::Duration::from_secs(5));
|
||||||
|
alarm.tick().await;
|
||||||
|
loop {
|
||||||
|
tokio::select! {
|
||||||
|
join_result = handles.join_next() => {
|
||||||
|
match join_result {
|
||||||
|
Some(handle) => match handle {
|
||||||
|
Ok(h) => println!("Stopped {h:?}"),
|
||||||
|
Err(e) => println!("Got error {e:?}"),
|
||||||
|
}
|
||||||
|
None => break,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ = alarm.tick() => {
|
||||||
|
println!("Exit timeout reached, aborting all unjoined tasks");
|
||||||
|
handles.abort_all();
|
||||||
|
break;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -35,5 +35,7 @@ fn main() -> error::Result<()> {
|
||||||
|
|
||||||
let mut app = App::new();
|
let mut app = App::new();
|
||||||
|
|
||||||
Ok(ratatui::run(|terminal| app.run(terminal, config, device))?)
|
Ok(ratatui::run(|terminal| {
|
||||||
|
app.start_and_run(terminal, config, device)
|
||||||
|
})?)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue