Expand description
CPU resources for the tcontract stack: scratch memory and contraction policy.
Placement (where tasks run, and how many at once) belongs to
strided_exec: a host owns a strided_exec::Pool, lends it through
Pool, and each operation takes an Exec, a bundle of one
strided_exec::Exec token, an optional workspace and a BatchPolicy.
This crate starts no task and exposes no scheduler type. See
PERFORMANCE_TIPS.md, CPU Threading Contract.
§Examples
use tcontract_exec::{Exec, Pool};
let sp = strided_exec::Pool::builder().threads(2).build().unwrap();
let pool = Pool::borrow(&sp);
let mut exec = Exec::new(&pool, 2).unwrap();
assert_eq!(exec.budget(), pool.size().min(2));
let total = std::sync::atomic::AtomicUsize::new(0);
exec.token().for_ranges(100, 1.try_into().unwrap(), |r| {
total.fetch_add(r.len(), std::sync::atomic::Ordering::Relaxed);
});
assert_eq!(total.into_inner(), 100);Re-exports§
pub use batch::BatchDecision;pub use batch::BatchPolicy;pub use batch::BatchQuery;pub use batch::BatchStrategy;pub use batch::WorkModel;
Modules§
- batch
- Batch lane policy: the shared vocabulary and the one decision function.
Structs§
- Arena
Provider - A workspace owner: per-thread worker slots plus a free list of team sets.
- Exec
- The resources one operation runs with: a placement token, optional reusable scratch, and the batch lane policy.
- Pool
- The CPU resources one owner lends to every operation: a
strided_exec::Pool(where tasks run) and anArenaProvider(where scratch lives). - Team
Lease - An exclusive loan of a team set, returned to its owner on drop.
- Width
Policy - Cost model for choosing a barrier-free partition width from the work.
- Workspace
- A caller-owned, bounded workspace: an
ArenaProviderpre-sized to oneWorkspaceReq, so a steady-state execute whose requirement is within the bound allocates nothing. - Workspace
Req - Bytes and counts one execute needs. Buffer sizes are bytes because the provider is element-type erased: the driver knows the element type and converts its real counts once.
- Workspace
Stats - What an owner currently holds and currently lends out.
Enums§
Traits§
- Workspace
Provider - Storage an execution may borrow. Implemented by the owner; the driver only ever sees this trait, so nothing here depends on the driver.