Skip to content

Commit

Permalink
chore(*): finalize SCC 2.1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
wvwwvwwv committed Sep 8, 2024
1 parent 6ea57eb commit 4781a0f
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
mod examples {
use scc::Queue;

#[test] // TODO: #156.
#[test]
fn single_threaded() {
let workload_size = 256;
let queue: Queue<isize> = Queue::default();
Expand Down
2 changes: 1 addition & 1 deletion examples/src/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
mod examples {
use scc::Stack;

#[test] // TODO: #156.
#[test]
fn single_threaded() {
let workload_size = 256;
let stack: Stack<isize> = Stack::default();
Expand Down
4 changes: 2 additions & 2 deletions src/hash_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,8 +1036,8 @@ where
/// let hashcache_default: HashCache<u64, u32> = HashCache::default();
/// assert_eq!(hashcache_default.capacity(), 0);
///
/// let hashcache: HashCache<u64, u32> = HashCache::with_capacity(1000000, 2000000);
/// assert_eq!(hashcache.capacity(), 1048576);
/// let hashcache: HashCache<u64, u32> = HashCache::with_capacity(1000, 2000);
/// assert_eq!(hashcache.capacity(), 1024);
/// ```
#[inline]
pub fn capacity(&self) -> usize {
Expand Down
4 changes: 2 additions & 2 deletions src/hash_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -991,8 +991,8 @@ where
/// assert!(hashindex_default.insert(1, 0).is_ok());
/// assert_eq!(hashindex_default.capacity(), 64);
///
/// let hashindex: HashIndex<u64, u32> = HashIndex::with_capacity(1000000);
/// assert_eq!(hashindex.capacity(), 1048576);
/// let hashindex: HashIndex<u64, u32> = HashIndex::with_capacity(1000);
/// assert_eq!(hashindex.capacity(), 1024);
/// ```
#[inline]
pub fn capacity(&self) -> usize {
Expand Down
4 changes: 2 additions & 2 deletions src/hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1384,8 +1384,8 @@ where
/// assert!(hashmap_default.insert(1, 0).is_ok());
/// assert_eq!(hashmap_default.capacity(), 64);
///
/// let hashmap: HashMap<u64, u32> = HashMap::with_capacity(1000000);
/// assert_eq!(hashmap.capacity(), 1048576);
/// let hashmap: HashMap<u64, u32> = HashMap::with_capacity(1000);
/// assert_eq!(hashmap.capacity(), 1024);
/// ```
#[inline]
pub fn capacity(&self) -> usize {
Expand Down
4 changes: 2 additions & 2 deletions src/hash_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,8 @@ where
/// assert!(hashset_default.insert(1).is_ok());
/// assert_eq!(hashset_default.capacity(), 64);
///
/// let hashset: HashSet<u64> = HashSet::with_capacity(1000000);
/// assert_eq!(hashset.capacity(), 1048576);
/// let hashset: HashSet<u64> = HashSet::with_capacity(1000);
/// assert_eq!(hashset.capacity(), 1024);
/// ```
#[inline]
pub fn capacity(&self) -> usize {
Expand Down
14 changes: 14 additions & 0 deletions src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,20 @@ impl<T> Default for Queue<T> {
}
}

impl<T> Drop for Queue<T> {
#[inline]
fn drop(&mut self) {
if !self.oldest.is_null(Relaxed) {
let guard = Guard::new();
let mut iter = self.iter(&guard);
while let Some(entry) = iter.current.as_ref() {
entry.delete_self(Relaxed);
iter.next();
}
}
}
}

impl<'g, T> FusedIterator for Iter<'g, T> {}

impl<'g, T> Iterator for Iter<'g, T> {
Expand Down
14 changes: 14 additions & 0 deletions src/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,20 @@ impl<T> Default for Stack<T> {
}
}

impl<T> Drop for Stack<T> {
#[inline]
fn drop(&mut self) {
if !self.newest.is_null(Relaxed) {
let guard = Guard::new();
let mut iter = self.iter(&guard);
while let Some(entry) = iter.current.as_ref() {
entry.delete_self(Relaxed);
iter.next();
}
}
}
}

impl<'g, T> FusedIterator for Iter<'g, T> {}

impl<'g, T> Iterator for Iter<'g, T> {
Expand Down
1 change: 0 additions & 1 deletion src/tests/correctness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2338,7 +2338,6 @@ mod treeindex_test {
}
}

#[cfg_attr(miri, ignore)] // TODO: #156.
#[test]
fn remove() {
let num_threads = if cfg!(miri) { 4 } else { 16 };
Expand Down
4 changes: 2 additions & 2 deletions src/tree_index/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::wait_queue::DeriveAsyncWait;
use std::borrow::Borrow;
use std::fmt::{self, Debug};
use std::ops::RangeBounds;
use std::sync::atomic::Ordering::{Acquire, Relaxed, Release};
use std::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed, Release};

/// [`Node`] is either [`Self::Internal`] or [`Self::Leaf`].
pub enum Node<K, V> {
Expand Down Expand Up @@ -309,7 +309,7 @@ where
}
};

match root.compare_exchange(root_ptr, (new_root, Tag::None), Release, Relaxed, guard) {
match root.compare_exchange(root_ptr, (new_root, Tag::None), AcqRel, Acquire, guard) {
Ok((_, new_root_ptr)) => {
root_ptr = new_root_ptr;
if let Some(internal_node_locker) = internal_node_locker {
Expand Down

0 comments on commit 4781a0f

Please sign in to comment.