parallel
Branches inside a global protocol that run at the same time. Nothing orders one branch's statements against another's, and the protocol continues past the block once every branch has finished.
component Radar;
component GroundStation;
component CommandPost;
message struct TrackReport {
track_id: uint32;
}
message struct Heartbeat {
uptime_s: uint32;
}
global protocol Watch {
parallel {
exch any TrackReport from Radar to CommandPost;
} with {
exch any Heartbeat from GroundStation to CommandPost;
}
}Branches
parallel { … } opens the first branch, and each with { … } after it adds another.
- Statements inside one branch keep their order. Statements in different branches have none relative to each other.
- A branch may be empty, and a
parallelwith nowithis one branch running by itself. - A branch holds any global statement, so a branch may exchange messages, loop, or choose.
- Nothing in a branch is in tail position, since the other branches continue after it.
- Branches that share a component describe that component doing two things at once, which is why the ordinary case is branches over disjoint components.
component Radar;
component GroundStation;
component CommandPost;
message struct TrackReport {
track_id: uint32;
}
message struct Heartbeat {
uptime_s: uint32;
}
message struct Ack {
track_id: uint32;
}
global protocol Watch {
parallel {
exch any TrackReport from Radar to CommandPost;
exch any Ack from CommandPost to Radar;
} with {
exch any Heartbeat from GroundStation to CommandPost;
}
exch any Ack from CommandPost to GroundStation;
}The Ack to Radar follows the TrackReport. Neither is ordered against the Heartbeat, and the
final Ack follows all three.
Related
- global protocol — the statement sequence a branch holds.
- exch — the interaction a branch is usually made of.
- choice — branches where one runs instead of all.