CSP for Java
(JCSP) 1.0-rc4

jcsp.lang
Class AltingChannelInputInt

java.lang.Object
  |
  +--jcsp.lang.Guard
        |
        +--jcsp.lang.AltingChannelInputInt
All Implemented Interfaces:
ChannelInputInt
Direct Known Subclasses:
AltingChannelInt

public abstract class AltingChannelInputInt
extends Guard
implements ChannelInputInt

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

Description

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

Example

 import jcsp.lang.*;
 
 public class AltingIntExample implements CSProcess {
 
   private final AltingChannelInputInt in0, in1;
   
   public AltingIntExample (final AltingChannelInputInt in0,
                            final AltingChannelInputInt in1) {
     this.in0 = in0;
     this.in1 = in1;
   }
 
   public void run () {
 
     final Guard[] altChans = {in0, in1};
     final Alternative alt = new Alternative (altChans);
 
     while (true) {
       switch (alt.select ()) {
         case 0:
           System.out.println ("in0 read " + in0.read ());
         break;
         case 1:
           System.out.println ("in1 read " + in1.read ());
         break;
       }
     }
 
   }
 
 }
 

Author:
P.D.Austin and P.H.Welch
See Also:
Guard, Alternative

Constructor Summary
AltingChannelInputInt()
           
 
Method Summary
abstract  boolean pending()
          Returns whether there is data pending on this channel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jcsp.lang.ChannelInputInt
read
 

Constructor Detail

AltingChannelInputInt

public AltingChannelInputInt()
Method Detail

pending

public abstract boolean pending()
Returns whether there is data pending on this channel.

Note: if there is, it won't go away until you read it. But if there isn't, there may be some by the time you check the result of this method.

Returns:
state of the channel.

CSP for Java
(JCSP) 1.0-rc4

Submit a bug or feature to jcsp-team@ukc.ac.uk
Version 1.0-rc4 of the JCSP API Specification (Copyright 1997-2000 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.