Skip to main content

Crate tcontract_exec

Crate tcontract_exec 

Source
Expand description

Explicit execution contexts for the tcontract stack.

A host lends its Rayon pool through Pool::borrow; operations take an Exec. Work of width one runs on the calling thread and never touches the pool; wider work enters the pool once, and not at all when the caller is already one of its workers. See PERFORMANCE_TIPS.md, CPU Threading Contract.

§Examples

use tcontract_exec::{Exec, Pool};
let tp = rayon::ThreadPoolBuilder::new().num_threads(2).build().unwrap();
let pool = Pool::borrow(&tp);
let exec = Exec::rayon(&pool);
let width = exec.install(2, |par| par.threads());
assert_eq!(width, 2);
assert_eq!(pool.stats().entries, 1);

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§

ArenaProvider
A workspace owner: per-thread worker slots plus a free list of team sets.
Pool
A wrapper around a host’s borrowed, owned or shared Rayon pool.
PoolStats
Counters of how often a Pool was entered, for tests and benchmarks.
TeamLease
An exclusive loan of a team set, returned to its owner on drop.
WidthPolicy
Cost model for choosing a barrier-free partition width from the work.
Workspace
A caller-owned, bounded workspace: an ArenaProvider pre-sized to one WorkspaceReq, so a steady-state execute whose requirement is within the bound allocates nothing.
WorkspaceReq
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.
WorkspaceStats
What an owner currently holds and currently lends out.

Enums§

Exec
Execution context passed to every operation that may run in parallel.
ExecError
Errors from building or using an Exec.
Par
Parallelism granted to an operation by Exec::install.

Traits§

WorkspaceProvider
Storage an execution may borrow. Implemented by the owner; the driver only ever sees this trait, so nothing here depends on the driver.