pub struct CpuBuilder { /* private fields */ }Expand description
Builder for acquiring a fabric CPU lease.
Allows specifying reserved CPU capacity and lease duration.
cores(n) reserves CPU capacity for the lease. In current tasklet
runtimes, execution width is still one tasklet thread per invocation unless
a future profile version defines otherwise.
§Examples
use grafos_std::cpu::CpuBuilder;
let lease = CpuBuilder::new().single_core().lease_secs(120).acquire()?;
// lease.cpu() is available for submit() callsImplementations§
Source§impl CpuBuilder
impl CpuBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new builder with defaults (1 core, 300s lease, no isolation preference — daemon default applies).
Sourcepub fn single_core(self) -> Self
pub fn single_core(self) -> Self
Convenience for the common case: reserve one CPU core for a single-threaded tasklet.
Sourcepub fn cores(self, n: u32) -> Self
pub fn cores(self, n: u32) -> Self
Set the number of CPU cores requested.
This reserves CPU capacity for the lease. It does not implicitly set tasklet execution width or create multiple tasklet worker threads.
Sourcepub fn isolation(self, class: CpuIsolationClass) -> Self
pub fn isolation(self, class: CpuIsolationClass) -> Self
Request a specific CPU isolation class for this lease.
When set, the daemon emits TLV_LEASE_CPU_ISOLATION (0x0902) on the
LEASE_ALLOC request. When omitted, the daemon’s
--cpu-isolation-policy default applies.
§Examples
use grafos_std::cpu::{CpuBuilder, CpuIsolationClass};
let lease = CpuBuilder::new()
.single_core()
.isolation(CpuIsolationClass::WholeCore)
.lease_secs(60)
.acquire()?;Sourcepub fn affinity(self, a: Affinity) -> Self
pub fn affinity(self, a: Affinity) -> Self
Add an affinity constraint (toward the target).
Multiple constraints may be added. Required constraints are hard filters; preferred constraints boost placement scoring.
§Examples
use grafos_std::cpu::CpuBuilder;
use grafos_std::affinity::{Affinity, Strength, Target};
let lease = CpuBuilder::new()
.single_core()
.affinity(Affinity::new(Strength::Preferred, Target::node(42)))
.lease_secs(60)
.acquire()?;Sourcepub fn anti_affinity(self, strength: Strength, target: Target) -> Self
pub fn anti_affinity(self, strength: Strength, target: Target) -> Self
Add an anti-affinity constraint (away from the target).
Shorthand for .affinity(Affinity::anti(strength, target)).
Sourcepub fn lease_secs(self, t: u32) -> Self
pub fn lease_secs(self, t: u32) -> Self
Set the lease duration in seconds.
Sourcepub fn acquire(self) -> Result<CpuLease>
pub fn acquire(self) -> Result<CpuLease>
Acquire a CPU lease.
§Errors
Returns crate::error::FabricError::CapacityExceeded or
crate::error::FabricError::Disconnected if the host cannot satisfy the request.