Skip to main content

Crate phasesmith_execution

Crate phasesmith_execution 

Source
Expand description

Explicit bounded execution contexts for native PhaseSmith kernels.

This crate owns reusable Rayon pools instead of installing or modifying the process-global pool. It gives desktop applications, services, Python adapters, and tests the same deterministic worker-budget contract. Applications normally use it through phasesmith::execution.

§Example

use phasesmith_execution::ExecutionPolicy;

let policy = ExecutionPolicy::new(Some(4), 2)?;
let results = policy.context().map_ordered(4, 2, |index| index * index);
assert_eq!(results, [0, 1, 4, 9]);
assert!(policy.resolved_budget() >= 1);

requested_threads = None selects available logical parallelism. Fixed requests are capped to what the process reports as available. Work below minimum_parallel_tasks remains serial, and ordered mapping always returns results in input order.

Structs§

ExecutionContext
Reusable, operation-owned worker pool with deterministic ordered mapping.
ExecutionPolicy
Immutable worker-budget policy with one persistent bounded execution pool.

Enums§

ExecutionPolicyError
Invalid or unconstructable native execution policy.

Constants§

DEFAULT_EXECUTION_THREADS
Default fixed worker budget used by scripts and applications.
DEFAULT_MINIMUM_PARALLEL_TASKS
Default number of independent tasks required before parallel scheduling.