From f7623e62643a41d7de873dd1904d7f8fc517a711 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Thu, 30 Jul 2020 09:59:02 +0100 Subject: [PATCH] [thin_check (rust)] remove spurious mutex. --- src/thin/check.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/thin/check.rs b/src/thin/check.rs index 471fad7..58c5ee3 100644 --- a/src/thin/check.rs +++ b/src/thin/check.rs @@ -146,7 +146,7 @@ trait NodeVisitor { #[derive(Clone)] struct BTreeWalker { - engine: Arc>, + engine: Arc, seen: Arc>, } @@ -154,7 +154,7 @@ impl BTreeWalker { fn new(engine: AsyncIoEngine) -> BTreeWalker { let nr_blocks = engine.get_nr_blocks() as usize; let r: BTreeWalker = BTreeWalker { - engine: Arc::new(Mutex::new(engine)), + engine: Arc::new(engine), seen: Arc::new(Mutex::new(FixedBitSet::with_capacity(nr_blocks))), }; r @@ -174,9 +174,7 @@ impl BTreeWalker { } drop(seen); - let mut engine = self.engine.lock().unwrap(); - engine.read_many(&mut blocks)?; - drop(engine); + self.engine.read_many(&mut blocks)?; for b in blocks { self.walk_node(visitor, &b)?; @@ -263,9 +261,7 @@ impl NodeVisitor for TopLevelVisitor { } drop(seen); - let mut engine = w.engine.lock().unwrap(); - engine.read_many(&mut blocks)?; - drop(engine); + w.engine.read_many(&mut blocks)?; // FIXME: with a thread pool we need to return errors another way. let nr_workers = 16;