mirror of
https://git.alemi.dev/dashboard.git
synced 2024-11-22 07:24:52 +01:00
fix: freezes on blocking operations
very cheap fix: spawn a thread to send the message. This is very wasteful, and should instead be done by spawning a task on the tokio runtime.
This commit is contained in:
parent
b2eb097585
commit
85f88fabc2
2 changed files with 30 additions and 14 deletions
|
@ -71,24 +71,41 @@ impl App {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn save_all_panels(&self) {
|
||||
if let Err(e) = self.view.op.blocking_send(
|
||||
crate::worker::visualizer::BackgroundAction::UpdateAllPanels { panels: self.panels.clone() }
|
||||
) {
|
||||
error!(target: "app", "Could not save panels: {:?}", e);
|
||||
}
|
||||
pub fn save_all_panels(&self) { // TODO can probably remove this and invoke op() directly
|
||||
let msg = BackgroundAction::UpdateAllPanels { panels: self.panels.clone() };
|
||||
self.op(msg);
|
||||
}
|
||||
|
||||
pub fn refresh_data(&self) {
|
||||
if let Err(e) = self.view.flush.blocking_send(()) {
|
||||
error!(target: "app", "Could not request flush: {:?}", e);
|
||||
let flush_clone = self.view.flush.clone();
|
||||
std::thread::spawn(move || {
|
||||
if let Err(e) = flush_clone.blocking_send(()) {
|
||||
error!(target: "app-background", "Could not request flush: {:?}", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
pub fn op(&self, op: BackgroundAction) {
|
||||
if let Err(e) = self.view.op.blocking_send(op) {
|
||||
error!(target: "app", "Could not send operation: {:?}", e);
|
||||
let op_clone = self.view.op.clone();
|
||||
std::thread::spawn(move || {
|
||||
if let Err(e) = op_clone.blocking_send(op) {
|
||||
error!(target: "app-background", "Could not send operation: {:?}", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn update_db_uri(&self) {
|
||||
let db_uri_clone = self.db_uri_tx.clone();
|
||||
let db_uri_str = self.db_uri.clone();
|
||||
let flush_clone = self.view.flush.clone();
|
||||
std::thread::spawn(move || {
|
||||
if let Err(e) = db_uri_clone.blocking_send(db_uri_str) {
|
||||
error!(target: "app-background", "Could not send new db uri : {:?}", e);
|
||||
}
|
||||
if let Err(e) = flush_clone.blocking_send(()) {
|
||||
error!(target: "app-background", "Could not request data flush : {:?}", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -313,8 +313,7 @@ pub fn header(app: &mut App, ui: &mut Ui, frame: &mut Frame) {
|
|||
.hint_text("db uri")
|
||||
.show(ui);
|
||||
if ui.button("connect").clicked() {
|
||||
app.db_uri_tx.blocking_send(app.db_uri.clone()).unwrap(); // TODO!!!
|
||||
app.refresh_data();
|
||||
app.update_db_uri();
|
||||
}
|
||||
ui.separator();
|
||||
let last_edit = app.edit; // replace panels when going into edit mode
|
||||
|
|
Loading…
Reference in a new issue