diff options
author | Alex Auvolat <alex@adnab.me> | 2022-12-14 12:51:16 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-12-14 12:51:42 +0100 |
commit | d56c472712df7c064387429a5af73d3bc0eb438d (patch) | |
tree | d3d73490ae3167a228ee91f69a583242c572cd9f /src/table/table.rs | |
parent | 2183518edccadef47cdeaf6476033b52d8832d6e (diff) | |
download | garage-d56c472712df7c064387429a5af73d3bc0eb438d.tar.gz garage-d56c472712df7c064387429a5af73d3bc0eb438d.zip |
Refactor background runner and get rid of job worker
Diffstat (limited to 'src/table/table.rs')
-rw-r--r-- | src/table/table.rs | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/table/table.rs b/src/table/table.rs index cb200ef2..4d93102e 100644 --- a/src/table/table.rs +++ b/src/table/table.rs @@ -14,6 +14,7 @@ use opentelemetry::{ use garage_db as db; +use garage_util::background::{self, BackgroundRunner}; use garage_util::data::*; use garage_util::error::Error; use garage_util::metrics::RecordDuration; @@ -96,13 +97,11 @@ where table } - pub fn spawn_workers(self: &Arc<Self>) { - self.merkle_updater.spawn_workers(&self.system.background); - self.syncer.spawn_workers(); - self.gc.spawn_workers(); - self.system - .background - .spawn_worker(InsertQueueWorker(self.clone())); + pub fn spawn_workers(self: &Arc<Self>, bg: &BackgroundRunner) { + self.merkle_updater.spawn_workers(bg); + self.syncer.spawn_workers(bg); + self.gc.spawn_workers(bg); + bg.spawn_worker(InsertQueueWorker(self.clone())); } pub async fn insert(&self, e: &F::E) -> Result<(), Error> { @@ -276,9 +275,7 @@ where if not_all_same { let self2 = self.clone(); let ent2 = ret_entry.clone(); - self.system - .background - .spawn_cancellable(async move { self2.repair_on_read(&who[..], ent2).await }); + background::spawn(async move { self2.repair_on_read(&who[..], ent2).await }); } } @@ -375,7 +372,7 @@ where .into_iter() .map(|k| ret.get(&k).unwrap().clone()) .collect::<Vec<_>>(); - self.system.background.spawn_cancellable(async move { + background::spawn(async move { for v in to_repair { self2.repair_on_read(&who[..], v).await?; } |