Class DelegatingSendPort<T>

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

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

      Fields 
      Modifier and Type Field Description
      protected SendPort<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.
      void close​(java.lang.Throwable t)
      Closes the channel so that no more messages could be sent to it, and signifies an exception occurred in the producer.
      boolean equals​(java.lang.Object obj)  
      int hashCode()  
      void send​(T message)
      Sends a message to the channel, possibly blocking until there's room available in the channel.
      boolean send​(T message, long timeout, java.util.concurrent.TimeUnit unit)
      Sends a message to the channel, possibly blocking until there's room available in the channel, but never longer than the specified timeout.
      boolean send​(T message, Timeout timeout)
      Sends a message to the channel, possibly blocking until there's room available in the channel, but never longer than the specified timeout.
      java.lang.String toString()  
      boolean trySend​(T message)
      Sends a message to the channel if the channel has room available.
      • Methods inherited from class java.lang.Object

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

    • Constructor Detail

      • DelegatingSendPort

        public DelegatingSendPort​(SendPort<T> target)
    • Method Detail

      • send

        public void send​(T message)
                  throws SuspendExecution,
                         java.lang.InterruptedException
        Description copied from interface: SendPort
        Sends a message to the channel, possibly blocking until there's room available in the channel. If the channel is full, this method may block, throw an exception, silently drop the message, or displace an old message from the channel. The behavior is determined by the channel's OverflowPolicy, set at construction time.
        Specified by:
        send in interface SendPort<T>
        Parameters:
        message - the message
        Throws:
        SuspendExecution
        java.lang.InterruptedException
      • send

        public boolean send​(T message,
                            long timeout,
                            java.util.concurrent.TimeUnit unit)
                     throws SuspendExecution,
                            java.lang.InterruptedException
        Description copied from interface: SendPort
        Sends a message to the channel, possibly blocking until there's room available in the channel, but never longer than the specified timeout. If the channel is full, this method may block, throw an exception, silently drop the message, or displace an old message from the channel. The behavior is determined by the channel's OverflowPolicy, set at construction time.
        Specified by:
        send in interface SendPort<T>
        Parameters:
        message - the message
        timeout - the maximum duration this method is allowed to wait.
        unit - the timeout's time unit
        Returns:
        true if the message has been sent successfully; false if the timeout has expired.
        Throws:
        SuspendExecution
        java.lang.InterruptedException
      • send

        public boolean send​(T message,
                            Timeout timeout)
                     throws SuspendExecution,
                            java.lang.InterruptedException
        Description copied from interface: SendPort
        Sends a message to the channel, possibly blocking until there's room available in the channel, but never longer than the specified timeout. If the channel is full, this method may block, throw an exception, silently drop the message, or displace an old message from the channel. The behavior is determined by the channel's OverflowPolicy, set at construction time.
        Specified by:
        send in interface SendPort<T>
        Parameters:
        message - the message
        timeout - the method will not block for longer than the amount remaining in the Timeout
        Returns:
        true if the message has been sent successfully; false if the timeout has expired.
        Throws:
        SuspendExecution
        java.lang.InterruptedException
      • trySend

        public boolean trySend​(T message)
        Description copied from interface: SendPort
        Sends a message to the channel if the channel has room available. This method never blocks.
        Specified by:
        trySend in interface SendPort<T>
        Parameters:
        message - the message
        Returns:
        true if the message has been sent; false otherwise.
      • close

        public void close​(java.lang.Throwable t)
        Description copied from interface: SendPort
        Closes the channel so that no more messages could be sent to it, and signifies an exception occurred in the producer. The exception will be thrown when the consumer calls ReceivePort's receive or tryReceive, wrapped by a ProducerException. Messages already sent to the channel prior to calling this method will still be received.
        Specified by:
        close in interface SendPort<T>
        Parameters:
        t - the exception causing the close
      • 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