fix: remove exit delay in gui mode, unused imports

This commit is contained in:
əlemi 2022-11-14 01:45:43 +01:00
parent 37fd0cda94
commit 54c61130f6
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 13 additions and 7 deletions

View file

@ -1,7 +1,5 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.10.1
use chrono::Utc;
use eframe::egui::plot::PlotPoint;
use sea_orm::entity::prelude::*;
use crate::data::FetchError;

View file

@ -178,15 +178,23 @@ fn main() {
.block_on(async {
let mut jobs = vec![];
let run_rx_clone_clone = run_rx.clone();
let mut run_rx_clone_clone = run_rx.clone();
jobs.push(
tokio::spawn(async move {
while *run_rx_clone_clone.borrow() {
if let Some(ctx) = &*ctx_rx.borrow() {
ctx.request_repaint();
loop {
// TODO probably state-worker can request a repaint directly, if we pass the
// channel used to receive ctx
tokio::select!{ // block on `run` too so that application can exit quickly
_ = run_rx_clone_clone.changed() => {
if ! *run_rx_clone_clone.borrow() { break; }
},
_ = tokio::time::sleep(std::time::Duration::from_secs(args.interval)) => {
if let Some(ctx) = &*ctx_rx.borrow() {
ctx.request_repaint();
}
},
}
tokio::time::sleep(std::time::Duration::from_secs(args.interval)).await;
}
})
);