mirror of
https://github.com/zerotier/common-utils.git
synced 2026-05-22 16:28:56 -07:00
Second get method in Pool to get or allocate if larger is needed.
This commit is contained in:
+10
@@ -298,6 +298,16 @@ impl Pool {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a buffer from the pool or direct allocation if min_capacity is larger than pool buffer capacity.
|
||||
#[inline]
|
||||
pub fn get_with_min_capacity(&self, min_capacity: usize) -> Buf {
|
||||
if unsafe { (*self.0).buf_capacity } >= min_capacity {
|
||||
self.get()
|
||||
} else {
|
||||
Buf::new(min_capacity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Pool {
|
||||
|
||||
Reference in New Issue
Block a user