Skip to content

[kotlin] Traverse workflow tree once per render pass instead of twice #904

@zach-klippenstein

Description

@zach-klippenstein

Currently we do two tree traversals per render pass:

  1. Render: Generate renderings, create new child workflows/workers, tear down old ones.
  2. Tick: Recursively select on all workers and event channels.

We should be able to reduce this to a single pass:

  1. Wrap the render pass in a select, and pass the SelectBuilder down through all the render calls.
  2. WorkflowNode.runningWorker adds each worker to the SelectBuilder as soon as it's ran.
  3. WorkflowNode.renderWithStateType adds its event channel to the SelectBuilder before returning.
  4. Once the root render call returns, offer the rendering to the rendering channel (it's conflated so no need to send).
  5. When the select returns, send the output to the output channel if non-null.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestkotlinAffects the Kotlin library.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions