Skip to content

Commit

Permalink
Decrement a ref count of node while iterating skiplist
Browse files Browse the repository at this point in the history
  • Loading branch information
topecongiro committed Feb 28, 2019
1 parent a007025 commit a6de0ca
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions crossbeam-skiplist/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1647,7 +1647,13 @@ where
pub fn next(&mut self, guard: &Guard) -> Option<RefEntry<'a, K, V>> {
self.parent.check_guard(guard);
self.head = match self.head {
Some(ref e) => e.next(guard),
Some(ref e) => {
let next_head = e.next(guard);
unsafe {
e.node.decrement(guard);
}
next_head
}
None => try_pin_loop(|| self.parent.front(guard)),
};
let mut finished = false;
Expand All @@ -1667,7 +1673,13 @@ where
pub fn next_back(&mut self, guard: &Guard) -> Option<RefEntry<'a, K, V>> {
self.parent.check_guard(guard);
self.tail = match self.tail {
Some(ref e) => e.prev(guard),
Some(ref e) => {
let next_tail = e.prev(guard);
unsafe {
e.node.decrement(guard);
}
next_tail
}
None => try_pin_loop(|| self.parent.back(guard)),
};
let mut finished = false;
Expand Down

0 comments on commit a6de0ca

Please sign in to comment.