Class DelegatingReceivePort<T>

  • All Implemented Interfaces:
    co.paralleluniverse.common.util.DelegatingEquals, Port<T>, PortAutoCloseable, ReceivePort<T>, java.lang.AutoCloseable
    Direct Known Subclasses:
    TransformingReceivePort

    public class DelegatingReceivePort<T>
    extends java.lang.Object
    implements ReceivePort<T>, co.paralleluniverse.common.util.DelegatingEquals
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected ReceivePort<T> target  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes the channel so that no more messages could be sent to it.
      boolean equals​(java.lang.Object obj)  
      int hashCode()  
      boolean isClosed()
      Tests whether the channel has been closed and no more messages await in the channel.
      T receive()
      Retrieves a message from the channels, possibly blocking until one becomes available.
      T receive​(long timeout, java.util.concurrent.TimeUnit unit)
      Retrieves a message from the channels, possibly blocking until one becomes available, but no longer than the specified timeout.
      T receive​(Timeout timeout)
      Retrieves a message from the channels, possibly blocking until one becomes available, but no longer than the specified timeout.
      java.lang.String toString()  
      T tryReceive()
      Retrieves a message from the channel if one is available.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • DelegatingReceivePort

        public DelegatingReceivePort​(ReceivePort<T> target)
    • Method Detail

      • receive

        public T receive​(long timeout,
                         java.util.concurrent.TimeUnit unit)
                  throws SuspendExecution,
                         java.lang.InterruptedException
        Description copied from interface: ReceivePort
        Retrieves a message from the channels, possibly blocking until one becomes available, but no longer than the specified timeout.
        Specified by:
        receive in interface ReceivePort<T>
        Parameters:
        timeout - the maximum duration to block waiting for a message.
        unit - the time unit of the timeout.
        Returns:
        a message, or null if the channel has been closed and no more messages await (see PortAutoCloseable.isClosed()), or if the timeout has expired.
        Throws:
        SuspendExecution
        java.lang.InterruptedException
      • receive

        public T receive​(Timeout timeout)
                  throws SuspendExecution,
                         java.lang.InterruptedException
        Description copied from interface: ReceivePort
        Retrieves a message from the channels, possibly blocking until one becomes available, but no longer than the specified timeout.
        Specified by:
        receive in interface ReceivePort<T>
        Parameters:
        timeout - the method will not block for longer than the amount remaining in the Timeout
        Returns:
        a message, or null if the channel has been closed and no more messages await (see PortAutoCloseable.isClosed()), or if the timeout has expired.
        Throws:
        SuspendExecution
        java.lang.InterruptedException
      • tryReceive

        public T tryReceive()
        Description copied from interface: ReceivePort
        Retrieves a message from the channel if one is available. This method never blocks.
        Specified by:
        tryReceive in interface ReceivePort<T>
        Returns:
        a message, or null if one is not immediately available.
      • close

        public void close()
        Description copied from interface: PortAutoCloseable
        Closes the channel so that no more messages could be sent to it. Messages already sent to the channel will still be received.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface PortAutoCloseable
      • isClosed

        public boolean isClosed()
        Description copied from interface: PortAutoCloseable
        Tests whether the channel has been closed and no more messages await in the channel. If this method returns true all future calls to receive are guaranteed to return null, and calls to receive on a primitive channel will throw a EOFException.
        Specified by:
        isClosed in interface PortAutoCloseable
        Returns:
        true if the channels has been closed and no more messages will be received; false otherwise.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Specified by:
        equals in interface co.paralleluniverse.common.util.DelegatingEquals
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object