pub struct ReadPool { /* private fields */ }Expand description
A bounded pool of reader connections. Clones share one pool.
Implementations§
Source§impl ReadPool
impl ReadPool
Sourcepub fn get(&self) -> Result<PooledReadConnection>
pub fn get(&self) -> Result<PooledReadConnection>
Checks out an idle reader, opens a new one while under the cap, or waits for a return.
Fails with DbError::ReadPoolClosed once the pool is closed, including while waiting.
Sourcepub fn close(&self)
pub fn close(&self)
Stops handing out readers and drops the idle ones now. A reader still checked out closes when it is returned. Calling it again does nothing.
Sourcepub fn close_and_wait(&self, timeout: Duration) -> Result<()>
pub fn close_and_wait(&self, timeout: Duration) -> Result<()>
Self::close, then waits up to timeout for every checked-out reader to be returned.
Ok(()) means every connection is closed and its database file released. Otherwise it
returns DbError::ReadPoolCloseTimeout with the number still out. Do not call it while
holding a reader from this pool: that reader cannot come back, so the call times out. A
timeout too large for the clock waits in bounded slices until the readers return.