Class FlatMappingReceivePort<S,​T>

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

    public class FlatMappingReceivePort<S,​T>
    extends java.lang.Object
    implements ReceivePort<T>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected ReceivePort<S> 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.
      protected ReceivePort<T> map​(S m)  
      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

      • FlatMappingReceivePort

        public FlatMappingReceivePort​(ReceivePort<S> target,
                                      com.google.common.base.Function<S,​ReceivePort<T>> f)
      • FlatMappingReceivePort

        public FlatMappingReceivePort​(ReceivePort<S> 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<S>
        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
      • 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<S>
        Returns:
        a message, or null if one is not immediately available.
      • 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<S>
        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
      • 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.
      • 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
      • 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