Skip to main content

Pool

Struct Pool 

Source
pub struct Pool { /* private fields */ }
Expand description

Connection reuse plus every client-wide deadline: idle connections and, when the host registers them, in-flight requests. One next_timeout covers all of them without visiting each connection or request.

Implementations§

Source§

impl Pool

Source

pub fn new(max_per_host: usize, idle: Duration) -> Self

Source

pub fn acquire(&mut self, key: &PoolKey, now: Instant) -> Acquire

A Connect reservation counts immediately, so concurrent callers cannot overbook.

Source

pub fn connected( &mut self, id: ConnectionId, protocol: Protocol, max_streams: usize, ) -> Result<()>

Source

pub fn release( &mut self, id: ConnectionId, reusable: bool, now: Instant, ) -> Result<()>

Source

pub fn closed(&mut self, id: ConnectionId) -> Result<()>

Source

pub fn contains(&self, id: ConnectionId) -> bool

Whether id still names a live connection: acquired and neither closed, forgotten nor expired by handle_timeout.

Source

pub fn forget(&mut self, id: ConnectionId) -> bool

Drop id whatever its state, for a host whose own socket table no longer has it (closed without telling the pool, or never found). Outstanding acquisitions go with it, so its per-host place is free for the next acquire. Returns whether id was live; a stale id is not an error.

Source

pub fn next_timeout(&self) -> Option<Instant>

The earliest idle-connection or registered request deadline, in O(1).

Source

pub fn handle_timeout(&mut self, now: Instant) -> Option<ConnectionId>

Repeatedly call to obtain all Close requests at this time. No clock or timer is owned.

Source

pub fn set_request_deadline(&mut self, id: RequestId, deadline: Option<Instant>)

Register (or with None clear) a request’s next deadline, typically the next_timeout() of its Lifecycle or Http1Connection after each call that may move it. The pool never inspects the request itself.

Source

pub fn request_deadline(&self, id: RequestId) -> Option<Instant>

Source

pub fn handle_request_timeout(&mut self, now: Instant) -> Option<RequestId>

Repeatedly call to obtain every request whose registered deadline is at or before now. Its registration is removed: call that request’s handle_timeout(now) and register its new next_timeout(), if any.

Auto Trait Implementations§

§

impl Forget for Pool

§

impl Freeze for Pool

§

impl RefUnwindSafe for Pool

§

impl Send for Pool

§

impl Sync for Pool

§

impl Unpin for Pool

§

impl UnsafeUnpin for Pool

§

impl UnwindSafe for Pool

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.