Skip to content

Commit

Permalink
Remove an implementation of PartialEq in RawShared
Browse files Browse the repository at this point in the history
  • Loading branch information
powergee committed Sep 30, 2024
1 parent 7e99db9 commit 97e7a22
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
22 changes: 10 additions & 12 deletions src/ebr_impl/pointers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,18 +252,6 @@ impl<'g, T> From<Tagged<T>> for RawShared<'g, T> {
}
}

impl<'g, T> PartialEq for RawShared<'g, T> {
/// Returns `true` if the two pointer values, including the tag values set by `with_tag`,
/// are identical.
fn eq(&self, other: &Self) -> bool {
// Instead of using a direct equality comparison (`==`), we use `ptr_eq`, which ignores
// the epoch tag in the high bits. This is because the epoch tags hold no significance
// for clients; they are only used internally by the CIRC engine to track the last
// accessed epoch for the pointer.
self.inner.ptr_eq(other.inner)
}
}

impl<'g, T> RawShared<'g, T> {
pub fn null() -> Self {
Self {
Expand Down Expand Up @@ -310,4 +298,14 @@ impl<'g, T> RawShared<'g, T> {
pub fn is_null(self) -> bool {
self.inner.is_null()
}

/// Returns `true` if the two pointer values, including the tag values set by `with_tag`,
/// are identical.
pub fn ptr_eq(&self, other: Self) -> bool {
// Instead of using a direct equality comparison (`==`), we use `ptr_eq`, which ignores
// the epoch tag in the high bits. This is because the epoch tags hold no significance
// for clients; they are only used internally by the CIRC engine to track the last
// accessed epoch for the pointer.
self.inner.ptr_eq(other.inner)
}
}
4 changes: 2 additions & 2 deletions src/ebr_impl/sync/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl<T> Queue<T> {
.map(|_| {
let tail = self.tail.load(Relaxed, guard);
// Advance the tail so that we don't retire a pointer to a reachable node.
if head == tail {
if head.ptr_eq(tail) {
let _ = self
.tail
.compare_exchange(tail, next, Release, Relaxed, guard);
Expand Down Expand Up @@ -154,7 +154,7 @@ impl<T> Queue<T> {
.map(|_| {
let tail = self.tail.load(Relaxed, guard);
// Advance the tail so that we don't retire a pointer to a reachable node.
if head == tail {
if head.ptr_eq(tail) {
let _ = self
.tail
.compare_exchange(tail, next, Release, Relaxed, guard);
Expand Down

0 comments on commit 97e7a22

Please sign in to comment.