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
impl Pool
pub fn new(max_per_host: usize, idle: Duration) -> Self
Sourcepub fn acquire(&mut self, key: &PoolKey, now: Instant) -> Acquire
pub fn acquire(&mut self, key: &PoolKey, now: Instant) -> Acquire
A Connect reservation counts immediately, so concurrent callers cannot overbook.
pub fn connected( &mut self, id: ConnectionId, protocol: Protocol, max_streams: usize, ) -> Result<()>
pub fn release( &mut self, id: ConnectionId, reusable: bool, now: Instant, ) -> Result<()>
pub fn closed(&mut self, id: ConnectionId) -> Result<()>
Sourcepub fn contains(&self, id: ConnectionId) -> bool
pub fn contains(&self, id: ConnectionId) -> bool
Whether id still names a live connection: acquired and neither closed,
forgotten nor expired by handle_timeout.
Sourcepub fn forget(&mut self, id: ConnectionId) -> bool
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.
Sourcepub fn next_timeout(&self) -> Option<Instant>
pub fn next_timeout(&self) -> Option<Instant>
The earliest idle-connection or registered request deadline, in O(1).
Sourcepub fn handle_timeout(&mut self, now: Instant) -> Option<ConnectionId>
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.
Sourcepub fn set_request_deadline(&mut self, id: RequestId, deadline: Option<Instant>)
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.
pub fn request_deadline(&self, id: RequestId) -> Option<Instant>
Sourcepub fn handle_request_timeout(&mut self, now: Instant) -> Option<RequestId>
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.