CSP for Java
(JCSP) 1.1-rc4

org.jcsp.lang
Class AltingChannelOutputInt

java.lang.Object
  extended by org.jcsp.lang.Guard
      extended by org.jcsp.lang.AltingChannelOutputInt
All Implemented Interfaces:
ChannelOutputInt, Poisonable

public abstract class AltingChannelOutputInt
extends Guard
implements ChannelOutputInt

This extends Guard and ChannelOutputInt to enable a process to choose between many integer output (and other) events.

A writing-end, obtained only from a symmetric channel by invoking its out() method, will implement this interface.

Description

AltingChannelOutputInt extends Guard and ChannelOutputInt to enable a process to choose between many integer output (and other) events. The methods inherited from Guard are of no concern to users of this package.

Example

 import org.jcsp.lang.*;
 
 public class AltingOutputIntExample implements CSProcess {
 
   private final AltingChannelOutputInt out0, out1;
   
   public AltingOutputIntExample (final AltingChannelOutputInt out0,
                                  final AltingChannelOutputInt out1) {
     this.out0 = out0;
     this.out1 = out1;
   }
 
   public void run () {
 
     final Guard[] altChans = {out0, out1};
     final Alternative alt = new Alternative (altChans);
 
     while (true) {
       switch (alt.select ()) {
         case 0:
           out0.write (0);
           System.out.println ("out0 written");
         break;
         case 1:
           out1.write (1);
           System.out.println ("out1 written");
         break;
       }
     }
 
   }
 
 }
 

Author:
P.H. Welch
See Also:
Guard, Alternative, One2OneChannelSymmetricInt, AltingChannelOutput

Constructor Summary
AltingChannelOutputInt()
           
 
Method Summary
abstract  boolean pending()
          Returns whether the receiver is committed to read from this channel.
 
Methods inherited from class org.jcsp.lang.Guard
schedule
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jcsp.lang.ChannelOutputInt
write
 
Methods inherited from interface org.jcsp.lang.Poisonable
poison
 

Constructor Detail

AltingChannelOutputInt

public AltingChannelOutputInt()
Method Detail

pending

public abstract boolean pending()
Returns whether the receiver is committed to read from this channel.

Note: if this returns true, you must commit to write down this channel.

Returns:
state of the channel.

CSP for Java
(JCSP) 1.1-rc4

Submit a bug or feature to jcsp-team@kent.ac.uk
Version 1.1-rc4 of the JCSP API Specification (Copyright 1997-2008 P.D.Austin and P.H.Welch - All Rights Reserved)
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.