Returns the current queue utilization as a percentage (0-100).
(&self)
| 196 | |
| 197 | /// Returns the current queue utilization as a percentage (0-100). |
| 198 | pub fn utilization(&self) -> u8 { |
| 199 | let tail = self.shared.tail.value.load(Ordering::Relaxed); |
| 200 | let head = self.shared.head.value.load(Ordering::Relaxed); |
| 201 | let pending = tail.wrapping_sub(head) as usize; |
| 202 | ((pending * 100) / self.shared.capacity) as u8 |
| 203 | } |
| 204 | |
| 205 | /// Returns the number of items currently in the queue. |
| 206 | pub fn len(&self) -> usize { |