aboutsummaryrefslogtreecommitdiff
path: root/src/background.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-04-22 17:04:33 +0000
committerAlex Auvolat <alex@adnab.me>2020-04-22 17:04:33 +0000
commit8971f34c816c42a0eb2bbcead5ac7f05854ddfb6 (patch)
tree8f2b272e1d033cab12b17271d036e3d1c0a183ba /src/background.rs
parente8214cb1807d3145907c7ed9e077fa45ada4aeea (diff)
downloadgarage-8971f34c816c42a0eb2bbcead5ac7f05854ddfb6.tar.gz
garage-8971f34c816c42a0eb2bbcead5ac7f05854ddfb6.zip
Well they still have to exit when we're exiting though
Diffstat (limited to 'src/background.rs')
-rw-r--r--src/background.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/background.rs b/src/background.rs
index f0dbdcb5..937062dd 100644
--- a/src/background.rs
+++ b/src/background.rs
@@ -2,6 +2,8 @@ use core::future::Future;
use std::pin::Pin;
use futures::future::join_all;
+use futures::select;
+use futures_util::future::*;
use std::sync::Arc;
use tokio::sync::Mutex;
use tokio::sync::{mpsc, watch, Notify};
@@ -88,7 +90,7 @@ impl BackgroundRunner {
}
async fn runner(self: Arc<Self>, i: usize) {
- let stop_signal = self.stop_signal.clone();
+ let mut stop_signal = self.stop_signal.clone();
loop {
let must_exit: bool = *stop_signal.borrow();
if let Some(job) = self.dequeue_job(must_exit).await {
@@ -100,7 +102,10 @@ impl BackgroundRunner {
info!("Background runner {} exiting", i);
return;
}
- self.job_notify.notified().await;
+ select! {
+ _ = self.job_notify.notified().fuse() => (),
+ _ = stop_signal.recv().fuse() => (),
+ }
}
}
}