pub struct GpuPool { /* private fields */ }Implementations§
Source§impl GpuPool
impl GpuPool
Sourcepub fn new(devices: &[GpuDevice]) -> Self
pub fn new(devices: &[GpuDevice]) -> Self
Build a pool from the host’s detected GPU inventory. An empty
inventory is permitted — the resulting pool always returns
None from claim() so CPU-only hosts work without
special-casing at the call site.
Sourcepub fn pending_claimers(&self) -> usize
pub fn pending_claimers(&self) -> usize
How many variant tasks are currently parked inside claim()
waiting for a permit. The LeaseArbiter consults this to decide
whether to dispatch a helper: when pending_claimers() > 0,
at least one variant task wants a GPU and the arbiter must
step back so the variant claims first (FIFO fairness).
Reads with Ordering::Acquire. The result is momentary — by
the time the caller observes it, a claim may have resolved or
a new one parked. That’s expected; the arbiter re-checks
before each dispatch decision.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
How many GPUs this pool manages. Useful for pre-spawning variants when fewer variants exist than GPUs (no point over-claiming).
Sourcepub fn snapshot_leases(&self) -> Vec<GpuLeaseEntry>
pub fn snapshot_leases(&self) -> Vec<GpuLeaseEntry>
Snapshot per-GPU lease state. Result preserves slot order
(matches the order GpuPool::new saw devices), so callers
stitching the result against the hello frame’s gpu_pool
see consistent indices across both reports.
Reads free slots with Ordering::Acquire. The result is a
momentary snapshot — by the time the caller observes it, a
claim or drop may have flipped any slot. That’s expected;
load reporting is best-effort observability, not a
transactional view.
Used by the worker’s Phase 2 (2026-05-07) load-tick task to
build the worker_load frame’s gpu_pool field.
Sourcepub async fn claim(self: &Arc<Self>) -> Option<GpuLease>
pub async fn claim(self: &Arc<Self>) -> Option<GpuLease>
Claim an available GPU. Awaits if every GPU is currently
leased. Returns None immediately on CPU-only hosts — the
caller should fall back to CPU encode.
Sourcepub fn try_claim(self: &Arc<Self>) -> Option<GpuLease>
pub fn try_claim(self: &Arc<Self>) -> Option<GpuLease>
Try to claim a GPU without blocking. Returns None if every
GPU is currently leased OR if the host has no GPUs.
Used by the LeaseArbiter (planned 2026-05-10) to grab a helper
lease without contending with blocked variant tasks. Tokio’s
Semaphore preserves FIFO ordering for queued waiters — a
permit released while a variant task is parked in
acquire_owned().await is reserved for that waiter and is NOT
visible to try_acquire_owned(), so this method cannot steal
a permit out from under a queued variant.
Does NOT increment pending_claimers; helpers are not blocked
claimers in the spare-capacity sense.