mirror of
https://git.alemi.dev/dashboard.git
synced 2024-11-14 11:59:18 +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) {
|
pub fn save_all_panels(&self) { // TODO can probably remove this and invoke op() directly
|
||||||
if let Err(e) = self.view.op.blocking_send(
|
let msg = BackgroundAction::UpdateAllPanels { panels: self.panels.clone() };
|
||||||
crate::worker::visualizer::BackgroundAction::UpdateAllPanels { panels: self.panels.clone() }
|
self.op(msg);
|
||||||
) {
|
|
||||||
error!(target: "app", "Could not save panels: {:?}", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn refresh_data(&self) {
|
pub fn refresh_data(&self) {
|
||||||
if let Err(e) = self.view.flush.blocking_send(()) {
|
let flush_clone = self.view.flush.clone();
|
||||||
error!(target: "app", "Could not request flush: {:?}", e);
|
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) {
|
pub fn op(&self, op: BackgroundAction) {
|
||||||
if let Err(e) = self.view.op.blocking_send(op) {
|
let op_clone = self.view.op.clone();
|
||||||
error!(target: "app", "Could not send operation: {:?}", e);
|
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")
|
.hint_text("db uri")
|
||||||
.show(ui);
|
.show(ui);
|
||||||
if ui.button("connect").clicked() {
|
if ui.button("connect").clicked() {
|
||||||
app.db_uri_tx.blocking_send(app.db_uri.clone()).unwrap(); // TODO!!!
|
app.update_db_uri();
|
||||||
app.refresh_data();
|
|
||||||
}
|
}
|
||||||
ui.separator();
|
ui.separator();
|
||||||
let last_edit = app.edit; // replace panels when going into edit mode
|
let last_edit = app.edit; // replace panels when going into edit mode
|
||||||
|
|
Loading…
Reference in a new issue