|
|
|
Reference Manual of LoI - Communication |
|
Communication is message-based. A message is send from one sender
to one or more receivers. It is assumed, that the message transfer is
reliable (messages do not get lost or are dublicated). The action of
sending is done immediately (the sender will not wait to check if the
message arrived at its receivers). Message reception may be blocking or
unblocking. Messages are additionally tagged with the communication
context of the sender. Thus, a potential receiver has to be in the
same communication context as the sender before it can actually
receive the message.
As the whole communication is asynchronous, all
incoming messages are hold in a buffer, until the receiving agent
queries for messages. Messages with different tags will be separated,
so that a mix-up of them will be no problem. To prevent that messages
with the same tag get mixed-up, you have to use different means.
The values with the following type can be send via messages: void,
aid, bool, mutex, int, float, object, char, string, constructor, port,
concrete types, arrays and tuples. The last three types include only
components of types that were listed before.
turn <an identifier> <a statement>
A communication context is set for the given statement using the given identifier. It will override an enclosing communication context.
<a selection of role> ? <parameters> <a selection or role> ?? <parameters> |
Both forms accept incoming messages. The first one blocks until a
message arrives (with the right communication context). In contrast to
that, the second form only checks, if a message is waiting for
reception. If that happens, the message will be processed like in the
first form. If no message is waiting, it will behave like the
statement fail (3.7.11)
If a message has arrived, its contents will be bound to the parameters
-form (cf. 3.4.5). If only one identifier is given the whole
content will be bound to it. If two or more identifiers (in
parentheses) are given, the content of the message has to be a tuple with
the same number of components. The components of the tuple are bound in
order to the identifiers.
Remark: This process of binding has the same effects as the declaration
of a variable (3.4.1).
<a selection of a role> ! <an expression>
The given expression will be evaluated and is sent to the selection (cf. 3.6.3.4).
There are three forms of composed utterances:
<a selection of a role> ! <an expression> ? <parameters> <a selection of a role> ? <parameters> ! <an expression> <a selection of a role> ?? <parameters> ! <an expression> |
Each of these forms are a composition of an input and output utterance. In the first one an output utterance is followed by input utterance. In the second and third form an input utterance is followed by an output utterance. They differ by using a blocking input utterance (the second form) in contrast to a non-blocking input utterance (the third form).
For all forms of utterances, expressions may be inserted, that are
executed locally at the agent which receives the message.
For input utterances this looks like
<a selection of a role> <? or ??> <an expression> -> <parameters>
The expression has to be a function. The
parameters of this function are bound to the arguments
of the input utterance which are supplied by the agent; the result of the
function is bound to the parameters of the utterance.
Note, that the expression may not contain any free variables.
For example, we have the following input utterance
|
On the side of the agent we do
R ! 2
The number will be bound to v and is squared. This operation is
executed local to the agent (in practice: on the same host and process
as the agent). The result is then transmitted and bound to v2.
Additionally, if we have to pass arguments to a locally executed
function, the following form can be used:
<a selection of a role> <? or ??>an expression> | <parameters>
The expression in front of the | symbol is passed to the locally executed expression of the corresponding output utterance (cf. below). It is possible to combine both forms:
<a selection of role> <? or ??> <an expression> | <an expression>
-> <parameters>
|
For an output utterance we have:
<a selection of role> ! <an expression> <- <an expression>
The expression after the exclamation mark has to be a function.
Its parameters are first bound
to the arguments of the output utterance; all remaining parameters are
bound to the arguments given by the receiving agent. The result of
function is passed to the agent.
Again, the expression which is executed locally, may only contain
bound variables.
E.g., we have this output utterance:
R ! (n,m) => n-m <- 3
The agent does
R ? 2 | r
The number 3 will be transmitted to the agent and bound to n; m is
bound to 2; the result of the expression (= 1) will be bound to r.
For composed utterances we get the following forms, which are handled
in accordance to the explanations given above:
<a selection of a role> ! <an expression> <- <an expression>
<? or ??> <an expression> -> <parameters>
<a selection of a role> ! <an expression> <<- <an expression>
<? or ??> <parameters>
<a selection of a role> ! <an expression>
<? or ??> <an expression> -> <parameters>
<a selection of a role> <? or ??> <an expression> -> <parameters>
! <an expression> <- <an expression>
<a selection of a role> <? or ??> <an expression> -> <parameters>
! <an expression>
<a selection of a role> <? or ??> <parameters>
! <an expression> <- <an expression>
|
In all cases it is possible to add arguments for locally executed code after question marks:
<a selection of role> ! <an expression> <-<an expression>
<? or ??> <an expression> | <an expression>
-> <parameters>
<a selection of role> ! <an expression> <- <an expression>
<? or ??> <an expression> | <parameters>
<a selection of role> ! <an expression>
<? or ??> <an expression> | <an expression>
-> <parameters>
<a selection of role> <? or ??> <an expression> | <an expression>
-> <parameters>
! <an expression><- <an expression>
<a selection of role> <? or ??> <an expression> | <an expression>
-> <parameters>
! <an expression>
<a selection of role> <? or ??> <an expression> | <parameters>
! <an expression> <- <an expression>
|
|
|
|
Reference Manual of LoI - Communication, © 2000 by Gil Müller |
|