americanexpress/unify-flowret

Where is synchronization point in parallel branch?

javanerd opened this issue · 3 comments

Hi Deepak,

first of all, I really appreciate your lightweight workflow solution. I have one important question. In the case of a parallel branching like here:

parallel flow

Is there really a synchronization point of joining all released threads? Or will they simply led through to the end step? What if after the join there would be another step? Where’s the mechanism that all threads are waiting until the steps 3a, 5 and 7 are finished. Can you give a short explanation?

Regards
J.

Yes, the sync point is the join. The next step after join would only get executed once all the threads reach join point. The framework manages this automatically for you. There can be different cases for example the parent thread at the route which triggered the child threads still waiting and all child threads reaching join in which case the parent will continue post that. Other variations could be that one of the child threads gets pended in which case the application overall will pend. When it is resumed, the behavior is slightly different. The child branch which had pended will be resumed through till join. Post that, it will be checked if there are any other child branches which are pended. If so, the application will again pend. If all others had completed, normal resumption would begin from join point onwards. Hope this clarifies.

Thanks in advance. I already understood that the join is the synchronization point. And also that there can be some reasons not all tasks can be completed. But, can you explain again where’s the logical point of synchronization in your code that let’s one thread executing some path waiting for other threads if it is done with its work? That is the key part I want to know.

Look up the file ExecThreadTask and the methods processParallelRoute / executeThreads.