Add some comments

This commit is contained in:
John Kåre Alsaker 2023-05-28 15:54:52 +02:00
parent 5843858c01
commit 8abafd085a

View file

@ -20,6 +20,9 @@
/// An array of cache-line aligned inner locked structures with convenience methods.
pub struct Sharded<T> {
/// This mask is used to ensure that accesses are inbounds of `shards`.
/// When dynamic thread safety is off, this field is set to 0 causing only
/// a single shard to be used for greater cache efficiency.
#[cfg(parallel_compiler)]
mask: usize,
shards: [CacheAligned<Lock<T>>; SHARDS],
@ -56,6 +59,7 @@ fn mask(&self) -> usize {
#[inline(always)]
fn count(&self) -> usize {
// `self.mask` is always one below the used shard count
self.mask() + 1
}