diff --git a/src/lockfree/queue.rs b/src/lockfree/queue.rs index a4ace84caa..01474e42da 100644 --- a/src/lockfree/queue.rs +++ b/src/lockfree/queue.rs @@ -66,6 +66,8 @@ impl Queue { }); loop { + guard.repin(); + // We push onto the tail, so we'll start optimistically by looking there first. let tail = self.tail.load(Acquire, guard); @@ -78,7 +80,6 @@ impl Queue { let _ = self .tail .compare_exchange(tail, next, Release, Relaxed, guard); - guard.repin(); continue; } @@ -96,7 +97,6 @@ impl Queue { } Err(e) => new = e.new, } - guard.repin(); } } @@ -105,6 +105,8 @@ impl Queue { /// Returns `None` if the queue is observed to be empty. pub fn try_pop(&self, guard: &mut Guard) -> Option { loop { + guard.repin(); + let head = self.head.load(Acquire, guard); let next = unsafe { head.deref() }.next.load(Acquire, guard); @@ -143,7 +145,6 @@ impl Queue { return Some(result); } - guard.repin(); } } }