[−][src]Struct ika::Pool
Let's go swimming!
Implementations
impl<T: Default> Pool<T>
[src]
pub fn new(size: usize) -> Self
[src]
Create a new pool with a maximum capacity of size
.
pub fn spawn(&mut self) -> Option<&mut T>
[src]
Instantiate an object.
Will return None if self.is_empty()
.
Object may have weird data, but it will have at least been initialized with T::default()
.
pub fn please_spawn(&mut self) -> &mut T
[src]
Please instantiate an object.
May allocate and resize the pool.
Object may have weird data, but it will have at least been initialized with T::default()
.
pub unsafe fn spawn_unchecked(&mut self) -> &mut T
[src]
Instantiate an object.
Undefined behavior if self.is_empty()
.
Object may have weird data, but it will have at least been initialized with T::default()
.
pub fn reclaim<F: FnMut(&T) -> bool>(&mut self, kill_fn: F)
[src]
Kill objects in the pool based on kill_fn
.
If kill_fn
returns true, the object will be recycled.
pub fn iter(&self) -> Iter<T>ⓘ
[src]
Returns an iterator over the pool.
pub fn iter_mut(&mut self) -> IterMut<T>ⓘ
[src]
Returns an iterator over the pool.
pub fn sort_the_dead(&mut self)
[src]
Sort pointers to available objects for better cache locality.
pub fn is_empty(&self) -> bool
[src]
Returns whether there are available objects in the pool or not.
pub fn available(&self) -> usize
[src]
Number of free objects in the pool.
impl<T: Recyclable> Pool<T>
[src]
pub fn spawn_new(&mut self) -> Option<&mut T>
[src]
Instantiate an object.
Will return None if self.is_empty()
.
Object will be reset based on its implementation of Recyclable.
pub unsafe fn spawn_new_unchecked(&mut self) -> &mut T
[src]
Instantiate an object.
Undefined behavior if self.is_empty()
.
Object will be reset based on its implementation of Recyclable.
Auto Trait Implementations
impl<T> RefUnwindSafe for Pool<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Pool<T> where
T: Send,
T: Send,
impl<T> Sync for Pool<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Pool<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Pool<T> where
T: UnwindSafe,
T: UnwindSafe,
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,
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.
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>,