Running commands in parallel

Commands in URBI can last during a certain amount of time, this is completely new compared to most other languages. We have seen so far that we can assign values with a certain time or with a certain speed, or even assign values in a sinusoidal way, which lasts forever. There are many ways in URBI to get these commands to run in parallel. We have already seen how to do it by using a comma to separate commands instead of a semicolon.

There is another way to specify that commands should be run in parallel, by using the & separator:

x = 4 time:1s & y = 2 speed:0.1;

The difference with the comma separator is that & forces the two commands to start at exactly the same time. In particular this means that the first command cannot start until the second command is fully available. So, typing x = 4 time:1s & in the console will not start anything, because URBI is waiting for what comes next, after the & (that's why we have the comma separator, which is less constraining and allow you run commands interactively).

In the same way commands can be run serially, exactly one after the other, by using a pipe separator:

x = 4 time:1s | y = 2 speed:0.1;

There will be no time gap between the two commands so, here again, URBI waits for the second command to be available: unlike the semicolon separated commands, the second command must start exactly after the first, so it must be ready in advance.

Using semicolon or comma separators is more permissive, because it will start immediately any command standing before the separator. But you might need strong time synchronization constraints, and that's why & and | separator are here for.

Note that you can group commands between brackets and build a more complex architecture of parallel and serial commands, like this:

{ { x = 4 time:1s | y = 2 speed:0.1 } & z = 0 sin:200ms ampli:4 } | t = 2,

TIP: In general, it is a good idea to end commands entered in a console (URBILab or telnet) by a comma, to avoid blocking the connection after entering a never-ending command.