Module cpu

Module cpu 

Source
Expand description

CPU tasklet resource module.

Provides typed access to fabric CPU resources via TASKLET_SUBMIT host functions. Programs submit WASM binaries for execution on remote fabric nodes with configurable fuel limits.

The underlying TASKLET_SUBMIT control op (0x0500) is implemented in fabricbiosd. On wasm32 targets, the host functions link to real imports (fabricbios_tasklet_v0). On native targets, mock implementations allow testing without a runtime.

§Example

use grafos_std::cpu::{CpuBuilder, FabricCpu};

let lease = CpuBuilder::new().single_core().lease_secs(60).acquire()?;
let result = lease.cpu().submit(&[0x00, 0x61, 0x73, 0x6d])
    .fuel(500_000)
    .input(b"test input")
    .launch()?;
assert_eq!(result.exit_code, 0);
assert_eq!(&result.output, b"hello");

Re-exports§

pub use crate::cpu_shared::partition;
pub use crate::cpu_shared::CoordinatorCtx;
pub use crate::cpu_shared::SharedRegion;
pub use crate::cpu_shared::SharedTaskletBuilder;
pub use crate::cpu_shared::SharedTaskletResult;
pub use crate::cpu_shared::TaskletError;
pub use crate::cpu_shared::WorkerCtx;
pub use crate::cpu_shared::WorkerScratch;

Structs§

CpuBuilder
Builder for acquiring a fabric CPU lease.
CpuLease
A CPU lease that auto-frees on drop.
FabricCpu
Safe handle to a fabric CPU resource for tasklet dispatch.
TaskletBuilder
Builder for configuring and launching a CPU tasklet.
TaskletResult
Result of a completed tasklet execution.

Enums§

CpuIsolationClass
Per-lease CPU isolation class.