pub struct ConnectionPool { /* private fields */ }Expand description
Lock-free connection pool using a lock-free idle queue and tokio::sync::Notify for efficient blocking when at capacity.
Design:
- Idle connections in SegQueue (lock-free, no contention).
- AtomicU32 tracks total connections (idle + borrowed).
- Notify wakes waiters when a connection is released.
- No mutexes, no spin-waiting, no semaphore overhead.
Implementations§
Source§impl ConnectionPool
impl ConnectionPool
pub async fn new(connection_string: &str, config: PoolConfig) -> Result<Self>
Sourcepub async fn acquire(&self) -> MCPResult<Arc<Client>>
pub async fn acquire(&self) -> MCPResult<Arc<Client>>
Acquire a connection from the pool.
Fast path: pop from idle queue (lock-free, ~20ns). Slow path: create new connection (up to max_size), or block via Notify.
pub fn active_count(&self) -> u32
pub fn max_size(&self) -> u32
Auto Trait Implementations§
impl !Freeze for ConnectionPool
impl RefUnwindSafe for ConnectionPool
impl Send for ConnectionPool
impl Sync for ConnectionPool
impl Unpin for ConnectionPool
impl UnsafeUnpin for ConnectionPool
impl UnwindSafe for ConnectionPool
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