Skip to content

Deflow algorithm

Gurmit Teotia edited this page Oct 25, 2018 · 27 revisions

Scheduling of activities, timer or any other child element is powered by simple yet powerful Dependency Flow (Deflow) algorithm. Deflow algorithm simplify the writing of complex workflows involving parallel execution of branches.

Deflow algorithm works as described below:

  1. Schedule startup items(activity, timer....) when workflow is started
  2. When a workflow item is completed then choose all of its children to schedule next
  3. Schedule a item only when all of its parent branches are inactive
  4. Trigger the scheduling of first joint item, according to step 3, when a branch becomes inactive

Above implementation of Deflow algorithm will work very well for many complex scenario, however you can customise any of above step in the workflow. Let us understand it further using through an example:

     A          B
     |          |
     C          D
     |          |
     ````````````
          |
          E
          |
          F
          |
          G
  • In above workflow A and B are startup activities which will be scheduled in parallel in when workflow is started
  • Activities C and D are scheduled when activities A and B are completed.
  • If activity C is completed before activity D (or other way round) then activity E will not be scheduled because its other parent branch B->D is still active. Later on when activity D is completed, then activity E is scheduled because all of its parent branches are inactive now.

Let us understand the point 4 for deflow algorithm through examples. A workflow branch becomes inactive when:

  • All of its items (activities, timer...) are completed.
  • A workflow item (activity, timer...) is jumping down the branch after joint item. e.g. in above case if activity B or D jumps down after first join item (activity E) to either F or G and branch B->D will become inactive.
  • A workflow item is not scheduled because "When" API is evaluated to false. e.g. if D is not scheduled because its When condition is evaluated to be false, then it will try to trigger the scheduling of activity E.
  • A workflow item has paused the execution of branch without keeping it active. e.g. if activity D pause the execution on its completion then branch B->D will become inactive.
Clone this wiki locally