[−][src]Struct lock_free_freelist::Reuse
This is a wrapper around smart pointers so that when they are dropped, raw pointers contained in them can be put to free list and reused.
This is produced by a FreeList. It is a smart pointer that contains shared ref to a FreeList instance and when the SmartPointer within it is about to drop, it takes the pointer inside of it and stores it in the free list instead.
It implements Deref and DerefMut to access the wrapped smart pointer.
Example
use lock_free_freelist::{FreeList, Reuse}; let free_list = FreeList::<Box<i32>>::new(); let reusable_box: Reuse<Box<i32>> = free_list.alloc(5); drop(reusable_box); // So that it can be reused let mut new_reusable_box: Reuse<Box<i32>> = free_list.reuse(9).unwrap(); assert_eq!(**new_reusable_box, 9);
Implementations
impl<'a, T: SmartPointer> Reuse<'a, T> where
<T as Deref>::Target: Sized + Reusable,
[src]
<T as Deref>::Target: Sized + Reusable,
pub fn new<'b>(smart_pointer: T, free_list: &'b FreeList<T>) -> Reuse<'b, T>
[src]
Get a new Reuse instance.
Trait Implementations
impl<'a, T: SmartPointer> Deref for Reuse<'a, T> where
<T as Deref>::Target: Sized + Reusable,
[src]
<T as Deref>::Target: Sized + Reusable,
impl<'a, T: SmartPointer> DerefMut for Reuse<'a, T> where
<T as Deref>::Target: Sized + Reusable,
[src]
<T as Deref>::Target: Sized + Reusable,
impl<'a, T: SmartPointer> Drop for Reuse<'a, T> where
<T as Deref>::Target: Sized + Reusable,
[src]
<T as Deref>::Target: Sized + Reusable,
When the instance of this type is dropped, an attempt is made to put the pointer of the contained SmartPointer into free list and if free list is full, the contents are dropped.
Auto Trait Implementations
impl<'a, T> !RefUnwindSafe for Reuse<'a, T>
impl<'a, T> Send for Reuse<'a, T> where
T: Send,
T: Send,
impl<'a, T> Sync for Reuse<'a, T> where
T: Sync,
T: Sync,
impl<'a, T> Unpin for Reuse<'a, T> where
T: Unpin,
T: Unpin,
impl<'a, T> !UnwindSafe for Reuse<'a, T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,