Skip to content

Commit

Permalink
feat(queue, stack): faster entry garbage collection
Browse files Browse the repository at this point in the history
Previously, popped entries are holding strong references to the next
one, even those having been deleted, thus causing a very slow garbage
collection of entries.

Now, deleted entries attached to an entry being dropped are immediately
passed to the garbage collector.
  • Loading branch information
wvwwvwwv committed Mar 5, 2024
1 parent 07300d0 commit 8cb3f3f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Version 2

2.0.17

* Faster `Queue` and `Stack` entry garbage collection.

2.0.16

* Fix an issue with `HashCache` where an evicted entry is dropped without notifying it when `HashCache` shrinks.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "scc"
description = "High performance containers and utilities for concurrent and asynchronous programming"
documentation = "https://docs.rs/scc"
version = "2.0.16"
version = "2.0.17"
authors = ["wvwwvwwv <[email protected]>"]
edition = "2021"
rust-version = "1.65.0"
Expand Down
9 changes: 9 additions & 0 deletions src/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,15 @@ impl<T> DerefMut for Entry<T> {
}
}

impl<T> Drop for Entry<T> {
#[inline]
fn drop(&mut self) {
if !self.next.is_null(Relaxed) {
self.next_ptr(Relaxed, &Guard::new());
}
}
}

impl<T: Display> Display for Entry<T> {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down

0 comments on commit 8cb3f3f

Please sign in to comment.