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);Structs§
- Arena
Provider - 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.
- Pool
Stats - Counters of how often a
Poolwas entered, for tests and benchmarks. - 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
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§
- Exec
- Execution context passed to every operation that may run in parallel.
- Exec
Error - Errors from building or using an
Exec. - Par
- Parallelism granted to an operation by
Exec::install.
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.