- pub fn insert(&mut self, item: &T, roll_duration: Duration) {
- if Instant::now() - self.last_roll > roll_duration / GENERATION_COUNT as u32 ||
- self.inserted_since_last_roll > ROLL_COUNT {
- self.current_generation += 1;
- if self.current_generation == GENERATION_COUNT as u8 + 1 { self.current_generation = 1; }
- let remove_generation = self.current_generation;
+ pub fn insert(&self, item: &T, roll_duration: Duration) {
+ let mut hashes = [None; HASHES];
+ for (idx, state) in self.hash_keys.iter().enumerate() {
+ let mut hasher = state.build_hasher();
+ item.hash(&mut hasher);
+ hashes[idx] = Some(hasher.finish() as usize);
+ }
+
+ let mut state = self.state.write().unwrap();
+ if Instant::now() - state.last_roll > roll_duration / GENERATION_COUNT as u32 ||
+ state.inserted_since_last_roll > ROLL_COUNT {
+ state.current_generation += 1;
+ if state.current_generation == GENERATION_COUNT as u8 + 1 { state.current_generation = 1; }
+ let remove_generation = state.current_generation;