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//! ```
20mod error;
21mod exec;
22mod pool;
23mod width;
24mod workspace;
25
26#[cfg(feature = "strided")]
27pub mod strided;
28
29pub use error::ExecError;
30pub use exec::{Exec, Par};
31pub use pool::{Pool, PoolStats};
32pub use width::WidthPolicy;
33pub use workspace::{ArenaProvider, TeamLease, WorkspaceProvider, WorkspaceReq, WorkspaceStats};