Try to set the size of this reservation to `capacity`
(&self, capacity: usize)
| 448 | |
| 449 | /// Try to set the size of this reservation to `capacity` |
| 450 | pub fn try_resize(&self, capacity: usize) -> Result<()> { |
| 451 | let size = self.size.load(atomic::Ordering::Relaxed); |
| 452 | match capacity.cmp(&size) { |
| 453 | Ordering::Greater => self.try_grow(capacity - size)?, |
| 454 | Ordering::Less => { |
| 455 | self.try_shrink(size - capacity)?; |
| 456 | } |
| 457 | _ => {} |
| 458 | }; |
| 459 | Ok(()) |
| 460 | } |
| 461 | |
| 462 | /// Increase the size of this reservation by `capacity` bytes |
| 463 | pub fn grow(&self, capacity: usize) { |