summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2022-01-11 20:26:06 -0500
committerJesse Luehrs <doy@tozt.net>2022-01-11 20:26:06 -0500
commitff51be1a0bec3d3f2161215949aa6afec00d8e2c (patch)
tree8b5042e29550f29d17b901ad56514408056108dc
parentdcb37735fb533e8903bfb613728d35c24100fb6a (diff)
downloadnbsh-ff51be1a0bec3d3f2161215949aa6afec00d8e2c.tar.gz
nbsh-ff51be1a0bec3d3f2161215949aa6afec00d8e2c.zip
move git calcuations to a background thread
since it can be slow
-rw-r--r--src/shell/mod.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/shell/mod.rs b/src/shell/mod.rs
index b934f07..e2ccf2d 100644
--- a/src/shell/mod.rs
+++ b/src/shell/mod.rs
@@ -120,7 +120,10 @@ pub async fn main() -> anyhow::Result<i32> {
async_std::task::spawn(async move {
while watch_r.recv().await.is_ok() {
let repo = git2::Repository::discover(&dir).ok();
- let info = repo.map(|repo| git::Info::new(&repo));
+ let info = blocking::unblock(|| {
+ repo.map(|repo| git::Info::new(&repo))
+ })
+ .await;
if event_w
.send(Event::GitInfo(info))
.await
@@ -134,7 +137,10 @@ pub async fn main() -> anyhow::Result<i32> {
} else {
_active_watcher = None;
}
- let info = repo.map(|repo| git::Info::new(&repo));
+ let info = blocking::unblock(|| {
+ repo.map(|repo| git::Info::new(&repo))
+ })
+ .await;
event_w.send(Event::GitInfo(info)).await.unwrap();
}
});