Check out the new USENIX Web site. next up previous
Next: Collaboration Up: Role Previous: The Daemon Role

Constructor and Destructor

Operators take and drop can be used to take a role and to drop a role respectively. In the following, R stands for the name of some role and $n\geq0$.
\begin{smallenum}
\item {\bf take} $R(T_{1}, T_{2}, ..., T_{n})$
\item {\bf drop} $R$\end{smallenum}

To perform initialization when a role is taken and to clean up when a role is dropped, we define constructor and destructor rules as follows.
\begin{smallenum}
\item {\bf on-take}($T_{1}, ..., T_{n}$) :- $p_{1}, ..., p_{m}$. 
\item {\bf on-drop} :- $p_{1}, ..., p_{m}$. \end{smallenum}
Arguments of the constructor rules are optional. For each role we can define one or more constructor rules which are fired at a cocavm when a participant takes on this role. Only the constructor whose arguments unify with those of the take predicate is chosen to execute upon initialization.

However, we define at most one destructor for each role. The destructor is fired at a cocavm when the role is dropped. At this point, it becomes inappropriate for any rules defined for that role to continue their execution. Our strategy is to mark all the arrival message and event queues in the cocavm so that no more messages or events will be processed after the mark. When the cocavm comes to a quiescent state, the destructor is fired to clean up.


next up previous
Next: Collaboration Up: Role Previous: The Daemon Role
Du Li
8/25/1999