pub struct LockFreePool<T: Send + 'static> { /* private fields */ }Implementations§
Source§impl<T: Send + 'static> LockFreePool<T>
impl<T: Send + 'static> LockFreePool<T>
Sourcepub fn new(
create: CreateFn<T>,
validate: ValidateFn<T>,
config: &PoolConfig,
) -> Self
pub fn new( create: CreateFn<T>, validate: ValidateFn<T>, config: &PoolConfig, ) -> Self
Create a new lock-free pool with the given factory and config.
All memory for the idle queue is pre-allocated at construction
(max_size slots). No heap allocation occurs on the hot path.
Sourcepub async fn acquire(&self) -> Result<PooledConnection<T>, PoolError>
pub async fn acquire(&self) -> Result<PooledConnection<T>, PoolError>
Acquire a connection from the pool.
§Fast path (common case, lock-free)
- Pop from idle queue (CAS loop, no syscall)
- Validate the connection (async SELECT 1)
- Return as PooledConnection
§Slow path (pool empty, not at capacity)
- CAS-increment size, create connection, return
§Wait path (pool empty, at capacity)
- Park on Notify with timeout, retry
pub fn close(&self)
pub fn is_closed(&self) -> bool
pub fn status(&self) -> PoolStatus
pub fn max_size(&self) -> u32
Trait Implementations§
Source§impl<T: Send + 'static> Clone for LockFreePool<T>
impl<T: Send + 'static> Clone for LockFreePool<T>
impl<T: Send + 'static> Send for LockFreePool<T>
impl<T: Send + 'static> Sync for LockFreePool<T>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for LockFreePool<T>
impl<T> !UnwindSafe for LockFreePool<T>
impl<T> Freeze for LockFreePool<T>
impl<T> Unpin for LockFreePool<T>
impl<T> UnsafeUnpin for LockFreePool<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