pub struct CpuShard(/* private fields */);
Expand description
Determine the right sharding by cpu, and minimise the cost of hashing function of remainder calculation.
§example:
use sync_utils::cpu::CpuShard;
let cpu_shard = CpuShard::new(Some(32));
let mut caches = Vec::with_capacity(cpu_shard.shards() as usize);
for _i in 0..caches.capacity() {
caches = Cache::new();
caches.push(cache);
}
let file_id = 111;
let shard_id = file_id & (caches.len() - 1 );
caches[shard_id].get(file_id);
Implementations§
Auto Trait Implementations§
impl Freeze for CpuShard
impl RefUnwindSafe for CpuShard
impl Send for CpuShard
impl Sync for CpuShard
impl Unpin for CpuShard
impl UnwindSafe for CpuShard
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