Skip to content

Commit

Permalink
chore(*): finalize SCC 2.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
wvwwvwwv committed Dec 22, 2023
1 parent 120d65d commit 0e4d67d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
13 changes: 7 additions & 6 deletions src/ebr/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,10 @@ impl Collector {
})
.map(|p| Tag::unset_tag(p).cast_mut());
if let Ok(mut collector_ptr) = lock_result {
#[allow(clippy::blocks_in_if_conditions)]
let _guard = ExitGuard::new(&GLOBAL_ANCHOR, |a| {
// Unlock the anchor.
while a
.fetch_update(Release, Relaxed, |p| {
loop {
let result = a.fetch_update(Release, Relaxed, |p| {
let tag = Tag::into_tag(p);
debug_assert!(tag == Tag::First || tag == Tag::Both);
let new_tag = if tag == Tag::Both {
Expand All @@ -247,9 +246,11 @@ impl Collector {
Tag::None
};
Some(Tag::update_tag(p, new_tag).cast_mut())
})
.is_err()
{}
});
if result.is_ok() {
break;
}
}
});

let known_epoch = self.state.load(Relaxed);
Expand Down
8 changes: 4 additions & 4 deletions src/hash_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -955,8 +955,8 @@ where

/// Returns the position of the key in the [`HashIndex`].
///
/// The method returns the index of the bucket associated with the key and the total number of
/// buckets in the [`HashIndex`], or `None` if the [`HashIndex`] is empty.
/// The method returns the index of the bucket associated with the key and the number of
/// buckets in the [`HashIndex`].
///
/// # Examples
///
Expand All @@ -965,12 +965,12 @@ where
///
/// let hashindex: HashIndex<u64, u32> = HashIndex::with_capacity(1024);
///
/// let (bucket_index, num_buckets) = hashindex.position(&11).unwrap();
/// let (bucket_index, num_buckets) = hashindex.position(&11);
/// assert_eq!(num_buckets, 32);
/// assert!(bucket_index < num_buckets);
/// ```
#[inline]
pub fn position<Q>(&self, key: &Q) -> Option<(usize, usize)>
pub fn position<Q>(&self, key: &Q) -> (usize, usize)
where
K: Borrow<Q>,
Q: Eq + Hash + ?Sized,
Expand Down
8 changes: 4 additions & 4 deletions src/hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1286,8 +1286,8 @@ where

/// Returns the position of the key in the [`HashMap`].
///
/// The method returns the index of the bucket associated with the key and the total number of
/// buckets in the [`HashMap`], or `None` if the [`HashMap`] is empty.
/// The method returns the index of the bucket associated with the key and the number of
/// buckets in the [`HashMap`].
///
/// # Examples
///
Expand All @@ -1296,12 +1296,12 @@ where
///
/// let hashmap: HashMap<u64, u32> = HashMap::with_capacity(1024);
///
/// let (bucket_index, num_buckets) = hashmap.position(&11).unwrap();
/// let (bucket_index, num_buckets) = hashmap.position(&11);
/// assert_eq!(num_buckets, 32);
/// assert!(bucket_index < num_buckets);
/// ```
#[inline]
pub fn position<Q>(&self, key: &Q) -> Option<(usize, usize)>
pub fn position<Q>(&self, key: &Q) -> (usize, usize)
where
K: Borrow<Q>,
Q: Eq + Hash + ?Sized,
Expand Down
8 changes: 4 additions & 4 deletions src/hash_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,8 @@ where

/// Returns the position of the key in the [`HashSet`].
///
/// The method returns the index of the bucket associated with the key and the total number of
/// buckets in the [`HashSet`], or `None` if the [`HashSet`] is empty.
/// The method returns the index of the bucket associated with the key and the number of
/// buckets in the [`HashSet`].
///
/// # Examples
///
Expand All @@ -625,12 +625,12 @@ where
///
/// let hashset: HashSet<u64> = HashSet::with_capacity(1024);
///
/// let (bucket_index, num_buckets) = hashset.position(&11).unwrap();
/// let (bucket_index, num_buckets) = hashset.position(&11);
/// assert_eq!(num_buckets, 32);
/// assert!(bucket_index < num_buckets);
/// ```
#[inline]
pub fn position<Q>(&self, key: &Q) -> Option<(usize, usize)>
pub fn position<Q>(&self, key: &Q) -> (usize, usize)
where
K: Borrow<Q>,
Q: Eq + Hash + ?Sized,
Expand Down
8 changes: 5 additions & 3 deletions src/hash_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,19 @@ where

/// Returns the expected bucket position of the key in the hash table.
///
/// `(bucket index, number of buckets)` is returned, or it returns `None` if it is empty.
/// `(bucket index, number of buckets)` is returned.
#[inline]
fn bucket_position<Q>(&self, key: &Q) -> Option<(usize, usize)>
fn bucket_position<Q>(&self, key: &Q) -> (usize, usize)
where
K: Borrow<Q>,
Q: Hash + ?Sized,
{
self.bucket_array()
.load(Acquire, &Guard::new())
.as_ref()
.map(|a| (a.calculate_bucket_index(self.hash(key)), a.num_buckets()))
.map_or((0, 0), |a| {
(a.calculate_bucket_index(self.hash(key)), a.num_buckets())
})
}

/// Returns the minimum allowed capacity.
Expand Down

0 comments on commit 0e4d67d

Please sign in to comment.