pub struct ExecutionContext {
pub threads: usize,
}Expand description
Advisory runtime information handed to a codec after construction.
The struct is deliberately tiny for now. New fields can be added
without breaking API consumers that already construct the value via
ExecutionContext::serial or ExecutionContext::with_threads.
Fields§
§threads: usizeAdvisory cap on how many threads a codec may use for its own
internal parallelism (slice-parallel decode, GOP-parallel decode,
etc.). Always ≥ 1. 1 means “caller requests serial execution
from this codec” — obey it unless you have a very good reason.
Implementations§
Source§impl ExecutionContext
impl ExecutionContext
Sourcepub fn with_threads(threads: usize) -> Self
pub fn with_threads(threads: usize) -> Self
Budget the codec to at most threads internal workers. Values
below 1 are clamped up to 1.
Sourcepub fn auto() -> Self
pub fn auto() -> Self
Derive the budget from the host:
std::thread::available_parallelism, falling back to 1 when
the host refuses to answer.
This is the caller-side convenience for “use the machine”.
Codecs never call it — they receive whatever budget the caller
chose and bound their fan-out with Self::effective_workers.
Sourcepub fn effective_workers(&self, work_units: usize) -> usize
pub fn effective_workers(&self, work_units: usize) -> usize
Bound a codec-internal fan-out: the number of workers to spawn
for work_units independent units of work under this budget.
Returns min(self.threads, work_units), and never less than 1
(work_units == 0 still yields 1 so degenerate inputs stay on
the plain serial path). This is the one clamp codecs use for
every slice-/tile-/field-/GOP-parallel dispatch; querying host
parallelism directly from codec code is out of contract.
Trait Implementations§
Source§impl Clone for ExecutionContext
impl Clone for ExecutionContext
Source§fn clone(&self) -> ExecutionContext
fn clone(&self) -> ExecutionContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more