[−][src]Struct lockfree_object_pool::MutexObjectPool
ObjectPool use a std::sync::Mutex over vector to secure multithread access to pull.
Example
use lockfree_object_pool::MutexObjectPool; let pool = MutexObjectPool::<u32>::new( || Default::default(), |v| { *v = 0; } ); let mut item = pool.pull(); *item = 5; let work = *item * 5;
Implementations
impl<T> MutexObjectPool<T>[src]
pub fn new<R, I>(init: I, reset: R) -> Self where
R: Fn(&mut T) + Send + Sync + 'static,
I: Fn() -> T + Send + Sync + 'static, [src]
R: Fn(&mut T) + Send + Sync + 'static,
I: Fn() -> T + Send + Sync + 'static,
Create an new MutexObjectPool
Arguments
initclosure to create new itemresetclosure to reset item before reusage
Example
use lockfree_object_pool::MutexObjectPool; let pool = MutexObjectPool::<u32>::new( || Default::default(), |v| { *v = 0; } );
pub fn pull(&self) -> MutexReusable<'_, T>[src]
Create a new element. When the element is dropped, it returns in the pull.
Example
use lockfree_object_pool::MutexObjectPool; let pool = MutexObjectPool::<u32>::new( || Default::default(), |v| { *v = 0; } ); let mut item = pool.pull();
Auto Trait Implementations
impl<T> !RefUnwindSafe for MutexObjectPool<T>[src]
impl<T> Send for MutexObjectPool<T> where
T: Send, [src]
T: Send,
impl<T> Sync for MutexObjectPool<T> where
T: Send, [src]
T: Send,
impl<T> Unpin for MutexObjectPool<T> where
T: Unpin, [src]
T: Unpin,
impl<T> !UnwindSafe for MutexObjectPool<T>[src]
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>,