flow-spec Pub

Testing the $flow

Let's use separate rules, to demonstrate this feature:

$when:: flow.start
   flow.step1
$when:: flow.start
   flow.step2
$when:: flow.start
   flow.step3
$when:: flow.start
   flow.step4

Because there is a $flow, the steps won't run in sequence as usual. Steps 2 and 3 will run in parallel - overall time should be around 3DUR, so less than 4DUR if the engine is not too busy...

$flow:: flow.start => ( flow.step1+( flow.step2|flow.step3 )+flow.step4 )

This rule matches each step and makes them all sleep:

$when:: /flow.step./.
   ctx.sleep (duration=DUR)
   . (dieselScope[="total"]=(total + 1))

Note that although some steps run in parallel, increasing that variable is safe. Only one executor at a time can modify values inside one engine!

The reason these actually run in parallel is because ctx.sleep is a truly asynchronous executor.

Other constructs

fcall | jplay | splay
def: my.func (p1, p2)
    diesel.get("error") + p1+p2


Was this useful?    

By: Razie | 2016-10-26 .. 2022-06-17 | Tags: spec , dsl , engine , private


Viewed 678 times ( | History | Print ) this page.

You need to log in to post a comment!

© Copyright DieselApps, 2012-2024, all rights reserved.