Syntax of Message Receive
- Receive is used to accept a message from another process
- receive followed by a series of patterns
- Patterns are matched sequentially
- Optional timeout to stop waiting for a message
- Generalized syntax (square brackets indicate optional elements)
receive
Message1 [when Guard1] -> % Guard can be is_XXX function or...
Actions1;
Message2 [when Guard1] -> % When clause tests or...
Actions2;
...
MessageN [when GuardN] -> % Math comparisons and guard built-ins.
ActionsN;
[after % Omission means wait forever
Milliseconds -> % Can be 0, positive integer or 'infinity'
TimeoutActions] % 0 returns immediately if no messages
end