pub struct SharedTaskletBuilder<'a, S, W>{ /* 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§
Sourcepub fn workers(self, n: u16) -> Self
pub fn workers(self, n: u16) -> Self
Number of worker lanes the runtime will launch (max_threads).
Must satisfy workers <= cores.
Size of the shared region in bytes.
Sourcepub fn scratch_bytes_per_worker(self, n: u32) -> Self
pub fn scratch_bytes_per_worker(self, n: u32) -> Self
Size of each worker’s private scratch region in bytes.
Sourcepub fn max_linear_memory(self, n: u32) -> Self
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.
Sourcepub fn with_max_fuel(self, max_fuel: u64) -> Self
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.
Sourcepub fn input(self, bytes: Vec<u8>) -> Self
pub fn input(self, bytes: Vec<u8>) -> Self
Input bytes the coordinator will read from shared memory.
Sourcepub fn launch<FCoord>(
self,
coordinator: FCoord,
) -> Result<SharedTaskletResult, TaskletError>
pub fn launch<FCoord>( self, coordinator: FCoord, ) -> Result<SharedTaskletResult, 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.