pub struct SplitOrderedList<V> {
list: List<usize, MaybeUninit<V>>,
buckets: GrowableArray<Node<usize, MaybeUninit<V>>>,
size: AtomicUsize,
count: AtomicUsize,
}
Expand description
Lock-free map from usize
in range [0, 2^63-1] to V
.
NOTE: We don’t care about hashing in this homework for simplicity.
Fields§
§list: List<usize, MaybeUninit<V>>
Lock-free list sorted by recursive-split order.
Use MaybeUninit::uninit()
when creating sentinel nodes.
buckets: GrowableArray<Node<usize, MaybeUninit<V>>>
Array of pointers to the buckets.
size: AtomicUsize
Number of buckets.
count: AtomicUsize
Number of items.
Implementations§
Source§impl<V> SplitOrderedList<V>
impl<V> SplitOrderedList<V>
Sourceconst LOAD_FACTOR: usize = 2usize
const LOAD_FACTOR: usize = 2usize
size
is doubled when count > size * LOAD_FACTOR
.
Sourcefn lookup_bucket<'s>(
&'s self,
index: usize,
guard: &'s Guard,
) -> Cursor<'s, usize, MaybeUninit<V>>
fn lookup_bucket<'s>( &'s self, index: usize, guard: &'s Guard, ) -> Cursor<'s, usize, MaybeUninit<V>>
Creates a cursor and moves it to the bucket for the given index. If the bucket doesn’t exist, recursively initializes the buckets.
Sourcefn find<'s>(
&'s self,
key: &usize,
guard: &'s Guard,
) -> (usize, bool, Cursor<'s, usize, MaybeUninit<V>>)
fn find<'s>( &'s self, key: &usize, guard: &'s Guard, ) -> (usize, bool, Cursor<'s, usize, MaybeUninit<V>>)
Moves the bucket cursor returned from lookup_bucket
to the position of the given key.
Returns (size, found, cursor)
fn assert_valid_key(key: usize)
Trait Implementations§
Source§impl<V> ConcurrentMap<usize, V> for SplitOrderedList<V>
impl<V> ConcurrentMap<usize, V> for SplitOrderedList<V>
Source§impl<V: Debug> Debug for SplitOrderedList<V>
impl<V: Debug> Debug for SplitOrderedList<V>
Auto Trait Implementations§
impl<V> !Freeze for SplitOrderedList<V>
impl<V> RefUnwindSafe for SplitOrderedList<V>where
V: RefUnwindSafe,
impl<V> Send for SplitOrderedList<V>
impl<V> Sync for SplitOrderedList<V>
impl<V> Unpin for SplitOrderedList<V>
impl<V> UnwindSafe for SplitOrderedList<V>where
V: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more