pub(super) struct PoolGuard<'a, T: Send, F: Fn() -> T> {
pool: &'a Pool<T, F>,
value: Result<Box<T>, usize>,
discard: bool,
}
Expand description
A guard that is returned when a caller requests a value from the pool.
Fields§
§pool: &'a Pool<T, F>
The pool that this guard is attached to.
value: Result<Box<T>, usize>
This is Err when the guard represents the special “owned” value.
In which case, the value is retrieved from ‘pool.owner_val’. And
in the special case of Err(THREAD_ID_DROPPED)
, it means the
guard has been put back into the pool and should no longer be used.
discard: bool
When true, the value should be discarded instead of being pushed back into the pool. We tend to use this under high contention, and this allows us to avoid inflating the size of the pool. (Because under contention, we tend to create more values instead of waiting for access to a stack of existing values.)
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<'a, T, F> Freeze for PoolGuard<'a, T, F>
impl<'a, T, F> RefUnwindSafe for PoolGuard<'a, T, F>
impl<'a, T, F> Send for PoolGuard<'a, T, F>
impl<'a, T, F> Sync for PoolGuard<'a, T, F>
impl<'a, T, F> Unpin for PoolGuard<'a, T, F>
impl<'a, T, F> UnwindSafe for PoolGuard<'a, T, F>
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