Skip to main content

tcontract_exec/
lib.rs

1//! Explicit execution contexts for the tcontract stack.
2//!
3//! A host lends its Rayon pool through [`Pool::borrow`]; operations take an
4//! [`Exec`]. Work of width one runs on the calling thread and never touches
5//! the pool; wider work enters the pool once, and not at all when the caller
6//! is already one of its workers. See `PERFORMANCE_TIPS.md`, CPU Threading
7//! Contract.
8//!
9//! # Examples
10//!
11//! ```
12//! use tcontract_exec::{Exec, Pool};
13//! let tp = rayon::ThreadPoolBuilder::new().num_threads(2).build().unwrap();
14//! let pool = Pool::borrow(&tp);
15//! let exec = Exec::rayon(&pool);
16//! let width = exec.install(2, |par| par.threads());
17//! assert_eq!(width, 2);
18//! assert_eq!(pool.stats().entries, 1);
19//! ```
20pub mod batch;
21mod error;
22mod exec;
23mod pool;
24mod width;
25mod workspace;
26
27#[cfg(feature = "strided")]
28pub mod strided;
29
30pub use batch::{BatchDecision, BatchPolicy, BatchQuery, BatchStrategy, WorkModel};
31pub use error::ExecError;
32pub use exec::{Exec, Par};
33pub use pool::{Pool, PoolStats};
34pub use width::WidthPolicy;
35pub use workspace::{
36    ArenaProvider, TeamLease, Workspace, WorkspaceProvider, WorkspaceReq, WorkspaceStats,
37};