Check out the new USENIX Web site. next up previous
Next: Events Up: Triveni: Design and Implementation Previous: Processes as Objects

   
Building Triveni processes

The combinators that build Triveni programs are presented in Figure 4. The presentation as a Composite pattern leaves Triveni open to the addition of new combinators.


  
Figure 4: The Expr combinators as a Composite
\begin{figure}\psfig{figure=figs/expr.eps,width=6.5in}\end{figure}

We first consider the Activity class. An Activity represents arbitrary code in the host programming language (say Java) that conforms to the interfaces Communicator and Controllable. The combinator ActivityExpr is used to embed an Activity in an Expr as its autonomous program. This allows the embedded Activity to be used as a subcomponent in the Expr and controlled by the Expr. In Triveni, the Activity class is actually a superclass (generalization) of the Expr class without the additional infrastructure that Expr provides for process composition.

  public abstract class Activity extends Communicator 
                              implements Controllable { ... }

Example 3  

The GUI components for the user interface of the player in Battle, such as Player and Opponent windows, are best realized as Activities. This allows the GUI components to be embedded in the Triveni program for Battle as controllable subcomponents.

The other combinators fall into the following categories. The Battle design example clarifies their semantics.

1.
Triveni allows event-based communication -- event emission (Emit), event renaming (Rename), and scoping in the form of local events (Local). Events are discussed in detail in Sections 3.3 and 3.4.

2.
Triveni supports the classical constructions from process algebra -- parallel composition (Parallel), sequential composition (Sequence), identity of sequential composition (Done), looping (Loop), waiting (potentially indefinitely) until a particular event happens (Await), and checking if the current event has a required label (Present).

3.
Triveni also supports the preemption combinators from synchronous programming. This includes a watchdog (DoWatching) that terminates execution when a particular event happens, and a combinator that suspends the execution on a particular event and resumes it on another event (SuspRes).

4.
In addition, Triveni provides structured interfaces (Valuator) to access the data carried on events and a combinator that branches on this information (Switch).


next up previous
Next: Events Up: Triveni: Design and Implementation Previous: Processes as Objects
1998-03-16