pub struct RcPool<T: Sized>(/* private fields */);Expand description
A single thread, interior mutable memory Pool backed by a reference count. This allows objects to hold references back to the pool to keep it alive without carrying a lifetime.
Implementations§
Trait Implementations§
Source§impl<T> AsRef<RcPool<RcInner<T>>> for Rc<T>
Get a reference to the pool this Rc was constructed from.
impl<T> AsRef<RcPool<RcInner<T>>> for Rc<T>
Get a reference to the pool this Rc was constructed from.
Source§impl<T> AsRef<RcPool<ScInner<T>>> for Sc<T>
Get a reference to the pool this Sc was constructed from.
impl<T> AsRef<RcPool<ScInner<T>>> for Sc<T>
Get a reference to the pool this Sc was constructed from.
Source§impl<T> AsRef<RcPool<T>> for Box<T>
Get a reference to the pool this Box was constructed from.
impl<T> AsRef<RcPool<T>> for Box<T>
Get a reference to the pool this Box was constructed from.
Source§impl<T> PoolApi<T> for RcPool<T>
impl<T> PoolApi<T> for RcPool<T>
Source§fn with_min_entries(&self, min_entries: usize)
fn with_min_entries(&self, min_entries: usize)
Configures the minimum of entries the first block will hold. Must be called before the
first allocation is made. Can be used when the number of entries that will be used is
roughly guessable and or the size of entries is small. Setting this improves cache
locality. Since blocks are allocated with exponentially growing size this should be
still small enough, approx 1/4 of the average number of entries to be expected. The
implementation will generously round this up to the next power of two. When not set it
defaults to 64 entries. Read more
Source§fn leak(self)
fn leak(self)
Destroys a Pool while leaking its allocated blocks. The fast way out when one knows
that allocations still exist and will never be returned to to the Pool. Either because
the program exits or because the allocations are meant to stay.
Source§fn alloc_entry(&self) -> NonNull<Entry<T>>
fn alloc_entry(&self) -> NonNull<Entry<T>>
Allocates a new entry, either from the freelist or by extending the pool.
Returns Entry pointer tagged as UNINITIALIZED.
Source§fn alloc(&self, t: T) -> Slot<T, Initialized>
fn alloc(&self, t: T) -> Slot<T, Initialized>
Allocates a new slot from the pool, initializes it with the supplied object and
returns a slot handle. Freeing the object should be done manually with
pool.free(),
pool::forget() or pool.take(). The user must take care that the slot/references
obtained from it are not used after free as this may panic or return another object.Source§unsafe fn free_by_ref<S: DropPolicy>(&self, slot: &mut Slot<T, S>)
unsafe fn free_by_ref<S: DropPolicy>(&self, slot: &mut Slot<T, S>)
Non consuming variant of
pool.free(), allows freeing slots that are part of other
structures while keeping Slot non-Copy. The slot must not be used after this.
See slot.free() for details.Source§unsafe fn take_by_ref<S: CanTakeValue>(&self, slot: &mut Slot<T, S>) -> T
unsafe fn take_by_ref<S: CanTakeValue>(&self, slot: &mut Slot<T, S>) -> T
Non consuming variant of
pool.take(), allows taking slots that are part of other
structures while keeping Slot non-Copy. The slot must not be used after this. See
slot.take() for details.Source§fn alloc_uninit(&self) -> Slot<T, Uninitialized>
fn alloc_uninit(&self) -> Slot<T, Uninitialized>
Allocates a new slot from the pool, keeps the content uninitialized returns a Slot
handle to it. Freeing the object should be done manually with
pool.free() or
pool.forget(). The user must take care that the provided handle or references
obtained from is are used after free as this may panic or return another object.Source§unsafe fn free<S: DropPolicy>(&self, slot: Slot<T, S>)
unsafe fn free<S: DropPolicy>(&self, slot: Slot<T, S>)
Frees
slot by calling its destructor when it contains an initialized object,
uninitialized objects become forgotten as with Pool::forget(). Puts the given slot
back into the freelist. Read moreSource§unsafe fn forget<S: Policy>(&self, slot: Slot<T, S>)
unsafe fn forget<S: Policy>(&self, slot: Slot<T, S>)
Puts the given slot back into the freelist. Will not call the the destructor. Read more
Source§unsafe fn forget_by_ref<S: Policy>(&self, slot: &mut Slot<T, S>)
unsafe fn forget_by_ref<S: Policy>(&self, slot: &mut Slot<T, S>)
Non consuming variant of
pool.forget(), allows forgetting slots that are part of
other structures while keeping Slot non-Copy. The slot must not be used after this.
See slot.forget() for details.Auto Trait Implementations§
impl<T> Freeze for RcPool<T>
impl<T> !RefUnwindSafe for RcPool<T>
impl<T> !Send for RcPool<T>
impl<T> !Sync for RcPool<T>
impl<T> Unpin for RcPool<T>
impl<T> !UnwindSafe for RcPool<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more