Use SpinLock on FileTable for efficiency

This commit is contained in:
Shaowei Song
2024-09-13 03:36:33 +00:00
committed by Tate, Hongliang Tian
parent 4a43e317b2
commit 1186fb7ca9
14 changed files with 108 additions and 66 deletions

View File

@ -52,6 +52,13 @@ impl<T> SlotVec<T> {
self.slots.get(idx)?.as_ref()
}
/// Get the mutable reference of the item at position `idx`.
///
/// Return `None` if `idx` is out of bounds or the item is not exist.
pub fn get_mut(&mut self, idx: usize) -> Option<&mut T> {
self.slots.get_mut(idx)?.as_mut()
}
/// Put an item into the vector.
/// It may be put into any existing empty slots or the back of the vector.
///