(slot_size: usize, initial_slots: usize)
| 36 | |
| 37 | impl SlabTier { |
| 38 | fn new(slot_size: usize, initial_slots: usize) -> Self { |
| 39 | let buf = vec![0u8; slot_size * initial_slots]; |
| 40 | let free_list: Vec<u32> = (0..initial_slots as u32).rev().collect(); |
| 41 | Self { |
| 42 | slot_size, |
| 43 | buf, |
| 44 | total_slots: initial_slots, |
| 45 | free_list, |
| 46 | occupied: 0, |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /// Allocate a slot. Returns the slot index, or None if the tier is full |
| 51 | /// (caller should grow the tier). |