pub struct VmPool { /* private fields */ }Expand description
Pool of pre-warmed branch Vms created from a VmSnapshot.
VmPool::acquire returns a ready-to-exec Linux micro-VM in sub-millisecond time while a
background thread replenishes the pool asynchronously. Dropping or calling
VmPool::shutdown cleanly shuts down every pre-warmed VM and stops replenishment.
Implementations§
Source§impl VmPool
impl VmPool
Sourcepub fn new(
snapshot: VmSnapshot,
size: usize,
net: Option<NetConfig>,
monitor: Option<MonitorConfig>,
) -> Result<Self>
pub fn new( snapshot: VmSnapshot, size: usize, net: Option<NetConfig>, monitor: Option<MonitorConfig>, ) -> Result<Self>
Pre-boot size warm branch VMs from snapshot in parallel and start background
replenishment.
Sourcepub fn acquire(&self) -> Result<Vm>
pub fn acquire(&self) -> Result<Vm>
Acquire a ready-to-exec warm Vm from the pool.
Returns immediately (< 1 ms) whenever a pre-warmed branch is queued, and wakes the background replenisher. If the pool is temporarily drained by burst callers, falls back to booting a fresh branch directly without blocking the replenisher.
Sourcepub fn available(&self) -> usize
pub fn available(&self) -> usize
Number of pre-warmed Vm instances currently queued and ready for instant VmPool::acquire.
Sourcepub fn target_size(&self) -> usize
pub fn target_size(&self) -> usize
Configured target number of pre-warmed Vm instances maintained by this pool.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for VmPool
impl !RefUnwindSafe for VmPool
impl !UnwindSafe for VmPool
impl Forget for VmPool
impl Move for VmPool
impl Send for VmPool
impl Sync for VmPool
impl Unpin for VmPool
impl UnsafeUnpin for VmPoolwhere
*const ArcInner<VmPoolInner> is !null: UnsafeUnpin,
PhantomData<ArcInner<VmPoolInner>>: UnsafeUnpin,
Align4<u32>: UnsafeUnpin,
Align1<u8>: UnsafeUnpin,
*const ArcInner<Inner> is !null: UnsafeUnpin,
PhantomData<ArcInner<Inner>>: UnsafeUnpin,
*const ArcInner<Packet<'static, ()>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Packet<'static, ()>>>: UnsafeUnpin,
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more