Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Both sides next revision | ||
alvis:proc [2014/09/02 09:49] marcin | — (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Proc statement ====== | ||
- | **Passive agents** are used to store data shared among agents and to avoid the simultaneous use of such data by two or more agents. They provide a set of **procedures** that can be called by other agents. Each procedure has its own port attached and a communication with a passive agent via that port is treated as the corresponding procedure call. Depending on the communication direction, such a procedure may be used to send or collect some data from the passive agent. Moreover, a passive agent may also contain internal non-procedure ports. Such ports are connected with another passive agents and are used to call other procedures inside procedures of the considered agent. | ||
- | |||
- | |||
- | < | ||
- | proc (g) p {...} | ||
- | </ | ||
- | |||
- | **Listing 1. ** Proc statement syntax, where '' | ||
- | |||
- | A procedure is accessible for other agents only if the guard evaluates to '' | ||
- | |||
- | A communication with a passive agent is treated as a procedure call. It can be initialised either by an active agent or by a passive one from inside of its procedure. In case of an input procedure (a parameter is sent to the corresponding passive agent), it is called with the **out** statement. After a procedure is started, its performs its statements. It is necessary to put the **in** statement as one of them -- the statement is used to collect the parameter, but it is not necessary to put the statement as the first procedure step. | ||
- | |||
- | Similarly, in case of an output procedure, | ||
- | |||
- | |||
- | ===== Example ===== | ||
- | |||
- | This is a part of a model only! | ||
- | |||
- | {{: | ||
- | |||
- | < | ||
- | agent Buffer { | ||
- | i :: Int = 0; | ||
- | proc pop { out pop i; exit; } | ||
- | proc push { in push i; exit; } | ||
- | } | ||
- | </ | ||
- | |||
- | |||
- | **[[: |