diff options
author | Alex Auvolat <alex@adnab.me> | 2020-04-22 16:51:52 +0000 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-04-22 16:51:52 +0000 |
commit | e8214cb1807d3145907c7ed9e077fa45ada4aeea (patch) | |
tree | 00192416f1c2d2157988a1c07df4601475a30a73 /src/table.rs | |
parent | c0335ac6904598b9ac367e17651da477d4d970d7 (diff) | |
download | garage-e8214cb1807d3145907c7ed9e077fa45ada4aeea.tar.gz garage-e8214cb1807d3145907c7ed9e077fa45ada4aeea.zip |
Better concurrency:
Use Notify instead of stupid sleep in background worker
Use Semaphore to limit concurrent requests in rpc_client
Make more background tasks cancellable
Diffstat (limited to 'src/table.rs')
-rw-r--r-- | src/table.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/table.rs b/src/table.rs index 3a21dfc7..bc375a96 100644 --- a/src/table.rs +++ b/src/table.rs @@ -269,7 +269,7 @@ where let ent2 = ret_entry.clone(); self.system .background - .spawn(async move { self2.repair_on_read(&who[..], ent2).await }); + .spawn_cancellable(async move { self2.repair_on_read(&who[..], ent2).await }); } } Ok(ret) @@ -324,7 +324,7 @@ where } if !to_repair.is_empty() { let self2 = self.clone(); - self.system.background.spawn(async move { + self.system.background.spawn_cancellable(async move { for (_, v) in to_repair.iter_mut() { self2.repair_on_read(&who[..], v.take().unwrap()).await?; } @@ -472,7 +472,7 @@ where self.instance.updated(old_entry, Some(new_entry)).await?; self.system .background - .spawn(syncer.clone().invalidate(tree_key)); + .spawn_cancellable(syncer.clone().invalidate(tree_key)); } } @@ -480,7 +480,7 @@ where let self2 = self.clone(); self.system .background - .spawn(async move { self2.insert_many(&epidemic_propagate[..]).await }); + .spawn_cancellable(async move { self2.insert_many(&epidemic_propagate[..]).await }); } Ok(()) @@ -500,7 +500,7 @@ where self.instance.updated(Some(old_entry), None).await?; self.system .background - .spawn(syncer.clone().invalidate(key.to_vec())); + .spawn_cancellable(syncer.clone().invalidate(key.to_vec())); count += 1; } } |