pub struct WeakHandle<'pool, T> { /* private fields */ }Expand description
A weak handle to a pool-allocated object.
Weak handles do not contribute to the reference count and do not
prevent the object from being returned to the pool. They can be
upgraded to a SharedHandle if the object is still alive.
§Examples
use fastalloc::{FixedPool, SharedHandle};
let pool = FixedPool::<i32>::new(10).unwrap();
// This is a simplified example showing the conceptImplementations§
Source§impl<'pool, T> WeakHandle<'pool, T>
impl<'pool, T> WeakHandle<'pool, T>
Sourcepub fn upgrade(&self) -> Option<SharedHandle<'pool, T>>
pub fn upgrade(&self) -> Option<SharedHandle<'pool, T>>
Attempts to upgrade this weak handle to a shared handle.
Returns None if the object has already been returned to the pool.
Sourcepub fn strong_count(&self) -> usize
pub fn strong_count(&self) -> usize
Returns the number of strong references to the object, if it still exists.
Sourcepub fn weak_count(&self) -> usize
pub fn weak_count(&self) -> usize
Returns the number of weak references to the object.
Trait Implementations§
Source§impl<'pool, T> Clone for WeakHandle<'pool, T>
impl<'pool, T> Clone for WeakHandle<'pool, T>
Auto Trait Implementations§
impl<'pool, T> Freeze for WeakHandle<'pool, T>
impl<'pool, T> !RefUnwindSafe for WeakHandle<'pool, T>
impl<'pool, T> !Send for WeakHandle<'pool, T>
impl<'pool, T> !Sync for WeakHandle<'pool, T>
impl<'pool, T> Unpin for WeakHandle<'pool, T>
impl<'pool, T> !UnwindSafe for WeakHandle<'pool, 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