From 8530a27488ff87b404fbaedf9f0c73c313c5e804 Mon Sep 17 00:00:00 2001 From: Andrew Fitzgerald Date: Wed, 26 Jun 2024 21:41:02 +0000 Subject: [PATCH] drain remove --- src/lock.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/lock.rs b/src/lock.rs index 248c1ec..652176c 100644 --- a/src/lock.rs +++ b/src/lock.rs @@ -44,9 +44,10 @@ impl Lock { return; } - for id in self.current_locks.drain(..) { - conflict_callback(&id); - } + // Only single lock, so call on the conflict and + // clear the current lock. + conflict_callback(¤t_write_id); + self.current_locks.clear(); self.kind = AccessKind::Read; self.current_locks.push(id); self.most_recent_write = Some(current_write_id); @@ -73,9 +74,11 @@ impl Lock { return; } - for id in self.current_locks.drain(..) { - conflict_callback(&id); - } + // Only single lock, so call on the conflict and + // clear the current lock. + conflict_callback(¤t_write_id); + self.current_locks.clear(); + self.current_locks.push(id); } }