SharedTaskletBuilder

Struct SharedTaskletBuilder 

Source
pub struct SharedTaskletBuilder<'a, S, W>
where S: Default + Send + Sync + 'static, W: Default + Send + 'static,
{ /* private fields */ }
Expand description

Builder for a shared-memory tasklet.

Construct via FabricCpu::shared_memory_tasklet. The builder is generic over the programmer’s shared-state type S and per-worker scratch type W. These are the types that the coordinator and workers see in their respective contexts.

The builder is intentionally distinct from crate::cpu::TaskletBuilder (the single-threaded path) so that “more cores” never silently means “more threads”: shared-memory execution is an explicit, named mode.

Implementations§

Source§

impl<'a, S, W> SharedTaskletBuilder<'a, S, W>
where S: Default + Send + Sync + 'static, W: Default + Send + 'static,

Source

pub fn cores(self, n: u16) -> Self

Number of CPU cores reserved for this tasklet (num_cores).

Source

pub fn workers(self, n: u16) -> Self

Number of worker lanes the runtime will launch (max_threads). Must satisfy workers <= cores.

Source

pub fn shared_bytes(self, n: u32) -> Self

Size of the shared region in bytes.

Source

pub fn scratch_bytes_per_worker(self, n: u32) -> Self

Size of each worker’s private scratch region in bytes.

Source

pub fn max_linear_memory(self, n: u32) -> Self

Override the per-tasklet linear-memory budget. Defaults to u32::MAX. shared + workers * scratch_per_worker must fit within this.

Source

pub fn fuel(self, n: u64) -> Self

Total fuel budget shared across coordinator and all workers.

Source

pub fn with_max_fuel(self, max_fuel: u64) -> Self

Phase 48.13 W2b — opt this builder into the V2 shared-pool fuel model with max_fuel units in the lease-wide pool.

When set, launch constructs an Arc<AtomicU64> initialized to max_fuel and installs it into each spawned worker’s WorkerSlot, plus the coordinator’s slot during the launch lifetime. The fuel_checkpoint SDK methods then CAS-decrement the pool the same way the wasmtime runtime does.

When unset (the default), no pool is installed and fuel_checkpoint returns Err(FuelExhausted) — this preserves the V1 behavior of all existing tests, which never call fuel_checkpoint and so observe identical behavior.

Source

pub fn input(self, bytes: Vec<u8>) -> Self

Input bytes the coordinator will read from shared memory.

Source

pub fn launch<FCoord>( self, coordinator: FCoord, ) -> Result<SharedTaskletResult, TaskletError>
where FCoord: FnOnce(&mut CoordinatorCtx<'_, S, W>) -> Result<(), TaskletError>,

Target-specific. Launch the tasklet on the host mock. This entry point is cfg-list: the wasm32 guest’s equivalent is [super::guest::run_shared_memory_tasklet], which has a different shape (it is called BY the runtime, not BY the program, and it takes both a coordinator closure and a worker closure because every worker lane re-enters tasklet_run).

Takes a single coordinator closure. The host mock drives data workers from inside CoordinatorCtx::parallel_for_workers, so there is no separate worker closure at launch time. Phase 48.14 removed the previous vestigial _worker parameter — it was never called on host and only masked the genuine cross-target shape difference.

The coordinator closure signature (FnOnce(&mut CoordinatorCtx<S, W>) -> Result<(), TaskletError>) is source-portable with the coordinator closure passed to run_shared_memory_tasklet on wasm32, so the closure body can live in a shared module while the two outer entry points live under #[cfg(target_arch = "wasm32")] gates. See the “Cross-target source patterns” section of docs/grafos/shared-memory-tasklet-build-guide.md.

Auto Trait Implementations§

§

impl<'a, S, W> Freeze for SharedTaskletBuilder<'a, S, W>

§

impl<'a, S, W> !RefUnwindSafe for SharedTaskletBuilder<'a, S, W>

§

impl<'a, S, W> !Send for SharedTaskletBuilder<'a, S, W>

§

impl<'a, S, W> !Sync for SharedTaskletBuilder<'a, S, W>

§

impl<'a, S, W> Unpin for SharedTaskletBuilder<'a, S, W>
where S: Unpin, W: Unpin,

§

impl<'a, S, W> !UnwindSafe for SharedTaskletBuilder<'a, S, W>

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.