Package org.jcsp.lang

Interface ChannelOutput

  • All Superinterfaces:
    Poisonable
    All Known Subinterfaces:
    FilteredChannelOutput, FilteredSharedChannelOutput, SharedChannelOutput
    All Known Implementing Classes:
    AltingChannelOutput, BlackHoleChannel, ChannelOutputWrapper, FilteredSharedChannelOutputWrapper

    public interface ChannelOutput
    extends Poisonable
    This defines the interface for writing to object channels.

    A writing-end, conforming to this interface, is obtained from a channel by invoking its out() method.

    Description

    ChannelOutput defines the interface for writing to object channels. The interface contains only one method - write(Object o). This method will block the calling process until the Object has been accepted by the channel. In the (default) case of a zero-buffered synchronising CSP channel, this happens only when a process at the other end of the channel invokes (or has already invoked) a read().

    ChannelOutput variables are used to hold channels that are going to be used only for output by the declaring process. This is a security matter -- by declaring a ChannelOutput interface, any attempt to input from the channel will generate a compile-time error. For example, the following code fragment will not compile:

     Object doRead (ChannelOutput c) {
       return c.read ();   // illegal
     }
     
    When configuring a CSProcess with output channels, they should be declared as ChannelOutput variables. The actual channel passed, of course, may belong to any channel class that implements ChannelOutput.

    Instances of any class may be written to a channel.

    Example

     void doWrite (ChannelOutput c, Object o) {
       c.write (o);
     }
     
    Author:
    P.D. Austin
    See Also:
    SharedChannelOutput, ChannelInput
    • Method Detail

      • write

        void write​(java.lang.Object object)
        Write an Object to the channel.
        Parameters:
        object - the object to write to the channel