Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
  • Loading branch information
SpadeA-Tang committed Mar 14, 2024
1 parent 69609ee commit fca44b4
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions crossbeam-skiplist/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2201,7 +2201,7 @@ fn below_upper_bound<T: Ord + ?Sized>(bound: &Bound<&T>, other: &T) -> bool {
///
/// You *must* call `release` to free this type, otherwise the node will be
/// leaked. This is because releasing the entry requires a `Guard`.
pub struct OwnedEntry<K, V> {
struct OwnedEntry<K, V> {
node: *const Node<K, V>,
released: bool,
}
Expand All @@ -2221,17 +2221,17 @@ impl<K, V> OwnedEntry<K, V> {
}

/// Returns a reference to the key.
pub fn key(&self) -> &K {
fn key(&self) -> &K {
unsafe { &(*self.node).key }
}

/// Returns a reference to the value.
pub fn value(&self) -> &V {
fn value(&self) -> &V {
unsafe { &(*self.node).value }
}

/// Releases the reference on the entry.
pub fn release(mut self, guard: &Guard) {
fn release(mut self, guard: &Guard) {
self.released = true;
unsafe { (*self.node).decrement(guard) }
}
Expand Down Expand Up @@ -2279,6 +2279,15 @@ where
}
}

impl<K, V> Drop for OwnedIter<K, V> {
fn drop(&mut self) {
if let Some(cursor) = self.cursor.take() {
let guard = &epoch::pin();
cursor.release(guard);
}
}
}

impl<K, V> OwnedIter<K, V>
where
K: Ord,
Expand Down

0 comments on commit fca44b4

Please sign in to comment.