From 320beb76f6fd76c5bbe49112762efeedb4f4a93c Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" <75863576+jeffwashington@users.noreply.github.com> Date: Tue, 28 Sep 2021 11:07:19 -0500 Subject: [PATCH] AcctIdx: implement wait_for_idle (#20256) --- runtime/src/bucket_map_holder.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/runtime/src/bucket_map_holder.rs b/runtime/src/bucket_map_holder.rs index 2efd7e359a..736cfdb61f 100644 --- a/runtime/src/bucket_map_holder.rs +++ b/runtime/src/bucket_map_holder.rs @@ -84,6 +84,19 @@ impl BucketMapHolder { pub(crate) fn wait_for_idle(&self) { assert!(self.get_startup()); + if self.disk.is_none() { + return; + } + + // when age has incremented twice, we know that we have made it through scanning all bins, so we are 'idle' + let end_age = self.current_age().wrapping_add(2); + loop { + self.wait_dirty_or_aged + .wait_timeout(Duration::from_millis(self.age_interval_ms())); + if end_age == self.current_age() { + break; + } + } } pub fn current_age(&self) -> Age {