Skip to content

Commit

Permalink
Use tokio::time:sleep over thread
Browse files Browse the repository at this point in the history
  • Loading branch information
vars1ty committed Oct 20, 2022
1 parent b8b2fd8 commit 2eadb49
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,15 @@ fn update_labels(update_rate: u64) {
"Label update received (from => \"{}\", to => \"{text}\")",
widget.label.text()
));

log("redrawing");
widget.label.set_text(&text)
}
}
std::thread::sleep(Duration::from_millis(update_rate));

// We could even remove this line, but it's staying because there's no need to update
// it 24/7.
tokio::time::sleep(Duration::from_millis(update_rate)).await;
}
});
}

0 comments on commit 2eadb49

Please sign in to comment.