Skip to main content

ExecutionUnit

Trait ExecutionUnit 

Source
pub trait ExecutionUnit:
    Send
    + Sized
    + 'static {
    type Constants: DeserializeOwned + 'static;

    const THREAD_COUNT_INVARIANT: bool = false;

    // Required methods
    fn initialize(
        constants: Self::Constants,
        schema: &SystemStateSchema,
        context: &InitializationContext,
    ) -> UnitResult<Self>;
    fn member_count(&self) -> usize;
    fn member(&self, index: usize) -> Option<MemberView<'_>>;
    fn step(&mut self) -> UnitResult;

    // Provided methods
    fn standard_state_schema() -> Option<StateSchemaProvider> { ... }
    fn preflight(
        _constants: &Self::Constants,
        _schema: &SystemStateSchema,
    ) -> UnitResult<ObservationPlan> { ... }
}
Expand description

One schedulable scientific execution containing one or more members.

Workflow manages every implementation through the same lifecycle and does not distinguish a standalone unit from a coordinated ensemble. A normal unit returns one MemberView; an ensemble returns one view per member and keeps all internal parallelism, shared inputs, and synchronization private. Each exposed member owns a distinct SystemState; Workflow rejects duplicate state addresses before beginning member recordings.

Member count, index order, identities, state owners, and schema allocations must remain stable after initialization. One successful Self::step must strictly advance at least one incomplete member and must never advance a member that was already complete. Other incomplete members may wait during a coordinated step, which permits synchronized ensembles and restored members at different iterations.

Provided Associated Constants§

Source

const THREAD_COUNT_INVARIANT: bool = false

Declares whether changing Rayon worker counts between coordinated steps preserves this unit’s scientific result.

Automatic compute allocation requires an explicit true; the default keeps fixed-width numerical units out of dynamically rebalanced runs.

Required Associated Types§

Source

type Constants: DeserializeOwned + 'static

One complete set of constants supplied by Config.

Required Methods§

Source

fn initialize( constants: Self::Constants, schema: &SystemStateSchema, context: &InitializationContext, ) -> UnitResult<Self>

Builds a fully initialized standalone unit or ensemble.

Every state subsequently exposed through Self::member must have been created from this exact schema allocation.

Source

fn member_count(&self) -> usize

Returns the stable positive number of independently stateful members.

Source

fn member(&self, index: usize) -> Option<MemberView<'_>>

Borrows one member by stable zero-based index.

The method must be side-effect free. Workflow calls it repeatedly before and after coordinated steps. An index below Self::member_count must always return Some; all other indices must return None.

Source

fn step(&mut self) -> UnitResult

Performs one coordinated scientific transition.

A standalone unit advances itself. An ensemble may advance members in parallel or share generated inputs, but it must return only after the complete logical step is visible through Self::member.

Provided Methods§

Source

fn standard_state_schema() -> Option<StateSchemaProvider>

Returns the standard static schema supplied for this unit, if any.

Study uses this provider only when the task omits an explicit project state. The default requires callers to select a project schema. An upstream provider owns the JSON document; this unit merely declares that it can receive states using that standard layout.

Source

fn preflight( _constants: &Self::Constants, _schema: &SystemStateSchema, ) -> UnitResult<ObservationPlan>

Validates unit-owned configuration and defines per-member observations.

All members of one execution unit use the state schema selected by the task and this common observation plan. The default records every field at every iteration without additional validation. An override owns all domain validation that can be performed before initialization; Study trusts a successful result. This preflight operation must not create output, initialize the unit, or mutate external state.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§