Package org.jcsp.lang

Class AltingChannelInputImpl<T>

java.lang.Object
org.jcsp.lang.Guard
org.jcsp.lang.AltingChannelInput<T>
org.jcsp.lang.AltingChannelInputImpl<T>
All Implemented Interfaces:
ChannelInput<T>, Poisonable

class AltingChannelInputImpl<T> extends AltingChannelInput<T>
  • Field Details

  • Constructor Details

    • AltingChannelInputImpl

      AltingChannelInputImpl(ChannelInternals<T> _channel, int _immunity)
  • Method Details

    • pending

      public boolean pending()
      Description copied from class: AltingChannelInput
      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.

      Specified by:
      pending in class AltingChannelInput<T>
      Returns:
      state of the channel.
    • disable

      boolean disable()
      Description copied from class: Guard
      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
    • enable

      boolean enable(Alternative alt)
      Description copied from class: Guard
      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
    • endRead

      public void endRead()
      Description copied from interface: ChannelInput
      End an extended rendezvous. It must be invoked once (and only once) following a startRead.
    • read

      public T read()
      Description copied from interface: ChannelInput
      Read an Object from the channel.
      Returns:
      the object read from the channel
    • startRead

      public T startRead()
      Description copied from interface: ChannelInput
      Begin an extended rendezvous read from the channel. An extended rendezvous is not completed until the reader has completed its extended action. This method starts an extended rendezvous. When a writer to this channel writes, this method returns what was sent immediately. The extended rendezvous continues with reader actions until the reader invokes endRead. Only then will the writer be released (from its write method). The writer is unaware of the extended nature of the communication.

      The reader process must call endRead at some point after this function, otherwise the writer will not be freed and deadlock will probably follow.

      The reader process may perform any actions between calling startRead and endRead, including communications on other channels. Further communications on this channel, of course, should not be made.

      An extended rendezvous may be started after the channel's Guard has been selected by an Alternative (i.e. startRead instead of read).

      Returns:
      The object read from the channel
    • poison

      public void poison(int strength)
      Description copied from interface: Poisonable
      This injects poison into the channel. If the channel was not explicitly constructed to be poisonable or if the strength of poison is not greater than the channel immunity level, the poison will have no effect.
      Parameters:
      strength - the strength of the poison (must be >= 0).