pub struct Pool<T> {
idle: Vec<Idle<T>>,
max_per_key: usize,
max_total: usize,
idle_ms: u64,
}Expand description
待っている接続の置き場。
Fields§
§idle: Vec<Idle<T>>§max_per_key: usize§max_total: usize§idle_ms: u64Implementations§
Source§impl<T> Pool<T>
impl<T> Pool<T>
Sourcepub const fn new(max_per_key: usize, max_total: usize, idle_ms: u64) -> Self
pub const fn new(max_per_key: usize, max_total: usize, idle_ms: u64) -> Self
max_per_key: 相手 1 つあたりの上限。max_total: 全体の上限。idle_ms: これより長く待った接続は使わない。
Sourcepub fn checkout(
&mut self,
key: &str,
now_ms: u64,
dropped: &mut Vec<T>,
) -> Option<T>
pub fn checkout( &mut self, key: &str, now_ms: u64, dropped: &mut Vec<T>, ) -> Option<T>
key の相手への接続を 1 本取り出す。一番新しく置いた物を渡す(相手が先に閉じている見込みが一番低い)。
待ちすぎた接続は dropped へ移す。生きているかどうかは呼ぶ側が確かめる。
Auto Trait Implementations§
impl<T> Freeze for Pool<T>
impl<T> RefUnwindSafe for Pool<T>where
T: RefUnwindSafe,
impl<T> Send for Pool<T>where
T: Send,
impl<T> Sync for Pool<T>where
T: Sync,
impl<T> Unpin for Pool<T>where
T: Unpin,
impl<T> UnsafeUnpin for Pool<T>
impl<T> UnwindSafe for Pool<T>where
T: UnwindSafe,
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