Process Pipeline Internals
This page documents the runtime path from Process(...) to loop execution.
1. Construction
Process(func, inputs_overrides...; lifetime, timeout) (src/Process.jl):
- Wrap bare
ProcessAlgorithmasSimpleAlgo. - Normalize lifetime (
Repeat(n)/Indefinite(), withRoutinedefaultRepeat(1)whenlifetime = nothing). - Build empty context:
ProcessContext(func). - Convert
Input/Overrideinto named backend forms via registry (resolve). - Build
TaskDataand initialize context viainitcontext(td).
2. Init Phase
initcontext (src/Init.jl) applies:
- Inputs merge (plus
algoandlifetimeinto every target subcontext). init(algo, input_context).- Overrides merge.
For loop algorithms, init(::LoopAlgorithm, ::ProcessContext) iterates all registry entities in order (src/LoopAlgorithms/Init.jl).
3. Running
run(p) (src/Interface.jl) ensures context is ready and calls makeloop! (src/Process.jl).
makeloop!:
- injects
processinto globals, - precompiles loop signature,
- spawns
generated_processloop(src/Running.jl).
4. generated_processloop
Defined in src/GeneratedCode/GeneratedLoops.jl for Repeat and Indefinite.
High-level structure:
before_while(process)- repeat/while body with inlined generated step expression
- tick/index increments
after_while(process, algo, context)
Step bodies are produced by step!_expr (src/LoopAlgorithms/GeneratedStep.jl and src/Identifiable/Step.jl) so composite/routine structures can be unrolled and specialized to concrete algorithm/context types.
5. Cleanup Behavior
after_while (src/Loops.jl) does:
- interrupted or indefinite: store current context, return it.
- natural finite completion: store
cleanup(func, context)into process context, then return the loop context.
So process state storage and task return value are related but not identical paths.