threadteam 0.1.0

Scoped CPU thread-team placement token: a Pool and a non-Clone Exec with fork, for_ranges, external and broadcast; no Rayon type in the public API.
Documentation
//! Splittable CPU placement token for the tensor4all CPU stack.
//!
//! `threadteam` is the single place that starts tasks. Kernels never see a
//! scheduler type: they take an [`Exec`], a token for `budget` slots of a
//! [`Pool`], and split it with [`Exec::fork`], [`Exec::for_ranges`],
//! [`Exec::broadcast`] or [`Exec::external`].
//!
//! * A [`Pool`] is built once by its owner with [`Pool::builder`].
//! * [`Exec::new`] mints a token from a pool; [`Exec::serial`] needs none.
//! * A token is not `Clone`/`Copy`; entries consume it; splits conserve slots.
//! * Serial, budget-one and one-task entries run inline and never reach any
//!   scheduler, so the process-global Rayon pool is never started implicitly.
//!
//! # Features
//!
//! * `parallel` (default): run on a private pool. Without it the same types
//!   exist, every pool has width 1 and every entry runs inline.
//! * `ledger`: test support, see the `ledger` module (compiled only with this feature).
//!
//! # Examples
//!
//! ```
//! use std::sync::atomic::{AtomicUsize, Ordering};
//! use threadteam::{Exec, Pool};
//!
//! let pool = Pool::builder().threads(4).build()?;
//! let mut exec = Exec::new(&pool, 4)?;
//!
//! // Phase 1: data-parallel loop.
//! let total = AtomicUsize::new(0);
//! exec.reborrow().for_ranges(1000, 64.try_into().unwrap(), |r| {
//!     total.fetch_add(r.len(), Ordering::Relaxed);
//! });
//! assert_eq!(total.into_inner(), 1000);
//!
//! // Phase 2: two independent parts, each with its share of the slots.
//! exec.fork(2, |_i, child| {
//!     assert!(child.budget().get() <= 2);
//! });
//! # Ok::<(), threadteam::Error>(())
//! ```

mod awake;
mod cost;
mod error;
mod exec;
#[cfg(feature = "ledger")]
pub mod ledger;
mod park;
mod policy;
mod pool;
mod reserve;
mod sched;
mod split;
mod sync;
mod team;
#[cfg(feature = "test-hooks")]
pub mod test_hooks;
#[cfg(feature = "trace")]
pub mod trace;
mod track;

pub use cost::{pays_at, width_for_by, DispatchCosts, DispatchKind, HostClass, WidthCosts, PAYS};
pub use error::{Error, Refused};
pub use exec::Exec;
#[cfg(loom)]
#[doc(hidden)]
pub use park::Parker;
pub use policy::{raise_current_thread_qos, Qos, WaitOverride, WaitPolicy};
pub use pool::{Pool, PoolBuilder};
pub use reserve::{IntoTeamError, Team};
pub use team::{Cancelled, Participant, TeamExec};

#[cfg(test)]
mod tests;