CpuBuilder

Struct CpuBuilder 

Source
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() calls

Implementations§

Source§

impl CpuBuilder

Source

pub fn new() -> Self

Create a new builder with defaults (1 core, 300s lease, no isolation preference — daemon default applies).

Source

pub fn single_core(self) -> Self

Convenience for the common case: reserve one CPU core for a single-threaded tasklet.

Source

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.

Source

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()?;
Source

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()?;
Source

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)).

Source

pub fn lease_secs(self, t: u32) -> Self

Set the lease duration in seconds.

Source

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.

Trait Implementations§

Source§

impl Default for CpuBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.