Package org.jcsp.lang

Class AltingChannelOutput<T>

  • All Implemented Interfaces:
    ChannelOutput<T>, Poisonable
    Direct Known Subclasses:
    AltingChannelOutputSymmetricImpl

    public abstract class AltingChannelOutput<T>
    extends Guard
    implements ChannelOutput<T>
    This extends Guard and ChannelOutput 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

    AltingChannelOutput extends Guard and ChannelOutput 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 AltingOutputExample implements CSProcess {
     
       private final AltingChannelOutput out0, out1;
       
       public AltingOutputExample (final AltingChannelOutput out0,
                                   final AltingChannelOutput 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 (new Integer (0));
               System.out.println ("out0 written");
             break;
             case 1:
               out1.write (new Integer (1));
               System.out.println ("out1 written");
             break;
           }
         }
     
       }
     
     }
     
    See Also:
    Guard, Alternative, One2OneChannelSymmetric, AltingChannelOutputInt
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      abstract boolean pending()
      Returns whether the receiver is committed to read from this channel.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AltingChannelOutput

        public AltingChannelOutput()
    • 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.