Package org.jcsp.lang

Class AltingConnectionServer<T>

java.lang.Object
org.jcsp.lang.Guard
org.jcsp.lang.AltingConnectionServer<T>
All Implemented Interfaces:
ConnectionServer<T>
Direct Known Subclasses:
AltingConnectionServerImpl, NetAltingConnectionServer

public abstract class AltingConnectionServer<T> extends Guard implements ConnectionServer<T>
An interface to connection. This is used by servers which wish to ALT over a connection. Note that you cannot have more than one server serving an AltingConnectionServer.
See Also:
  • Field Details

  • Constructor Details

    • AltingConnectionServer

      protected AltingConnectionServer(AltingChannelInput<ConnectionMessage<T>> altingChannel)
      Constructor. Note that this is only intended for use by JCSP, and should not be called by user processes. Users should use one of the subclasses.
      Parameters:
      altingChannel - The channel used to implement the Guard
  • Method Details

    • getAltingChannel

      protected AltingChannelInput<ConnectionMessage<T>> getAltingChannel()
      Returns the channel used to implement the Guard. Note that this method is only intended for use by JCSP, and should not be called by user processes. Concrete subclasses should override this method to return null, to ensure that the alting channel is kept private.
      Returns:
      The channel passed to the constructor.
    • setAltingChannel

      protected void setAltingChannel(AltingChannelInput<ConnectionMessage<T>> chan)
      ConnectionServer implementations are likely to be implemented over channels. Multiple channels from the client to server may be used; one could be used for the initial connection while another one could be used for data requests. This method allows sub-classes to specify which channel should be the next one to be alted over.
      Parameters:
      chan - the channel to be ALTed over.
    • enable

      boolean enable(Alternative alt)
      Returns true if the event is ready. Otherwise, this enables the guard for selection and returns false.

      Note: this method should only be called by the Alternative class

      Specified by:
      enable in class Guard
      Parameters:
      alt - the Alternative class that is controlling the selection
      Returns:
      true if and only if the event is ready
    • disable

      boolean disable()
      Disables the guard for selection. Returns true if the event was ready.

      Note: this method should only be called by the Alternative class

      Specified by:
      disable in class Guard
      Returns:
      true if and only if the event was ready
    • pending

      public boolean pending()
      Returns whether there is an open() pending on this connection.

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

      Returns:
      true only if open() will complete without blocking.