resurect addref and unref since tests use 'em for now
This commit is contained in:
committed by
Jeff Washington (jwash)
parent
7bccdc5251
commit
e4103b5886
@ -161,6 +161,18 @@ impl<T: Clone + Copy> Bucket<T> {
|
||||
Err(BucketMapError::IndexNoSpace(index.capacity_pow2))
|
||||
}
|
||||
|
||||
pub fn addref(&mut self, key: &Pubkey) -> Option<RefCount> {
|
||||
let (elem, _) = self.find_entry_mut(key)?;
|
||||
elem.ref_count += 1;
|
||||
Some(elem.ref_count)
|
||||
}
|
||||
|
||||
pub fn unref(&mut self, key: &Pubkey) -> Option<RefCount> {
|
||||
let (elem, _) = self.find_entry_mut(key)?;
|
||||
elem.ref_count -= 1;
|
||||
Some(elem.ref_count)
|
||||
}
|
||||
|
||||
fn create_key(&self, key: &Pubkey, ref_count: u64) -> Result<u64, BucketMapError> {
|
||||
Self::bucket_create_key(
|
||||
&self.index,
|
||||
|
@ -196,6 +196,20 @@ impl<T: Clone + Copy + Debug> BucketMap<T> {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
/// Increment the refcount for Pubkey `key`
|
||||
pub fn addref(&self, key: &Pubkey) -> Option<RefCount> {
|
||||
let ix = self.bucket_ix(key);
|
||||
let mut bucket = self.buckets[ix].write().unwrap();
|
||||
bucket.as_mut()?.addref(key)
|
||||
}
|
||||
|
||||
/// Decrement the refcount for Pubkey `key`
|
||||
pub fn unref(&self, key: &Pubkey) -> Option<RefCount> {
|
||||
let ix = self.bucket_ix(key);
|
||||
let mut bucket = self.buckets[ix].write().unwrap();
|
||||
bucket.as_mut()?.unref(key)
|
||||
}
|
||||
}
|
||||
|
||||
/// Look at the first 8 bytes of the input and reinterpret them as a u64
|
||||
|
Reference in New Issue
Block a user