Skip to content

How to implement multiple CONDITION tasks triggering a common successor as a logical OR? #709

Description

@wicyn

🧠 Description:

In my current Taskflow-based task graph, I have multiple CONDITION tasks. Each of these condition tasks may independently decide whether to proceed to a shared successor task. However, Taskflow's current behavior is such that:

If multiple CONDITION tasks are connected directly to the same successor task, and more than one condition is satisfied, the successor may be executed multiple times.

This leads to unintended duplicate execution of the shared successor.


✅ What I want:

I would like to implement a logical OR behavior across multiple CONDITION tasks. That is:

  • As soon as one CONDITION task evaluates true, the shared successor task is triggered.
  • The successor should only execute once, even if multiple conditions are satisfied in parallel.
  • Ideally, this could be done elegantly within Taskflow, without managing a lot of external state or condition flags manually.

❓My question:

Is there a recommended pattern or mechanism in Taskflow to handle this situation, such as:

  • Using a proxy/gate task that all CONDITION tasks jump to, which in turn ensures single execution of the successor?
  • Any idiomatic way to model this OR-type fan-in logic using the existing Taskflow API?

💡 Example Illustration (what I want):

[ condition_A ] ─┐
[ condition_B ] ─┴──> [gate/collector task] ──> target_task (only if any condition == true)

Each condition runs independently, and the gate task collects the results after all condition tasks complete, decides if the target should proceed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions