Skip to content

Commit

Permalink
use atomic mask
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt authored and samuelcolvin committed Sep 9, 2024
1 parent 66f0bfe commit 9c67b85
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions crates/jiter/src/lazy_index_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::fmt;
use std::hash::{DefaultHasher, Hash, Hasher};
use std::mem::MaybeUninit;
use std::slice::Iter as SliceIter;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::atomic::{AtomicU16, AtomicUsize, Ordering};

use ahash::RandomState;
use bitvec::order::Lsb0;
Expand Down Expand Up @@ -144,6 +144,8 @@ where
}

mod index_map_vec {
use std::sync::atomic::AtomicU16;

use super::*;

pub(super) struct LazyIndexMapArray<K, V> {
Expand All @@ -153,7 +155,7 @@ mod index_map_vec {
duplicates_mask: DuplicatesMask,
}

type DuplicatesMask = bitvec::BitArr!(for HASHMAP_THRESHOLD, in Cell<u16>);
type DuplicatesMask = bitvec::BitArr!(for HASHMAP_THRESHOLD, in AtomicU16);

impl<K, V> LazyIndexMapArray<K, V> {
pub fn new() -> Self {
Expand Down Expand Up @@ -321,7 +323,7 @@ enum LazyIndexMapIter<'a, K, V> {
Vec {
iter: SliceIter<'a, (K, V)>,
// to mask duplicate entries
mask: <bitvec::BitArr!(for HASHMAP_THRESHOLD, in Cell<u16>) as IntoIterator>::IntoIter,
mask: <bitvec::BitArr!(for HASHMAP_THRESHOLD, in AtomicU16) as IntoIterator>::IntoIter,
},
Map(indexmap::map::Iter<'a, K, V>),
}
Expand Down

0 comments on commit 9c67b85

Please sign in to comment.