pub struct Reservoir<M: Detach> { /* private fields */ }Expand description
A bounded, lock-free pool of detached connections shared by every thread.
Idle connections beyond a shard’s min_idle are
detached into this queue, where any thread may claim them. Both ends are
wait-free in the common case: ArrayQueue is a fixed-size ring, so
parking and stealing never allocate and never take a lock. The only async
step, Detach::attach, runs after the entry is already out of the queue.
§Platform support
Only construct this where Detach is sound: io_uring and poll drivers
treat attach as a no-op, so fds move freely. Under IOCP a handle is bound
to one completion port for life. See Detach for the details.
Implementations§
Trait Implementations§
Source§impl<M: Detach> Exchange<M> for Reservoir<M>
impl<M: Detach> Exchange<M> for Reservoir<M>
Source§fn park(&self, conn: M::Connection, meta: SlotMeta) -> Parked<M>
fn park(&self, conn: M::Connection, meta: SlotMeta) -> Parked<M>
Offers an idle connection to other threads. Must not block.
Source§async fn unpark(&self) -> Unparked<M>
async fn unpark(&self) -> Unparked<M>
Tries to claim a connection parked by another thread and reattach it
to this one.
Source§fn clear(&self)
fn clear(&self)
Drops every parked connection. Called by
Pool::close.Auto Trait Implementations§
impl<M> !Freeze for Reservoir<M>
impl<M> RefUnwindSafe for Reservoir<M>
impl<M> Send for Reservoir<M>
impl<M> Sync for Reservoir<M>
impl<M> Unpin for Reservoir<M>
impl<M> UnsafeUnpin for Reservoir<M>
impl<M> UnwindSafe for Reservoir<M>
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