Calculates counter age, while considering a possibility of wraparound (with the assumption that wraparound will happen at most once) `global_value` > `item_value` indicates that wraparound has happened. In that case, the age is calculated taking that into consideration.
(global_value: u32, item_value: u32)
| 15 | // consideration. |
| 16 | // |
| 17 | fn counter_age(global_value: u32, item_value: u32) -> u32 { |
| 18 | if global_value >= item_value { |
| 19 | global_value - item_value |
| 20 | } else { |
| 21 | // until wrap around + after wraparound |
| 22 | (u32::MAX - item_value) + global_value |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | pub struct EvictionIndex { |
| 27 | inner: [AtomicU64; 256], |
no outgoing calls
no test coverage detected