Class ThreadSendPort<Message>


  • public class ThreadSendPort<Message>
    extends java.lang.Object
    This class is a simple convenience wrapper around SendPort that can be used by threads (as opposed to fibers). Its methods do not declare they throw SuspendExecution.
    • 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()  
      void send​(Message message)
      Sends a message to the channel, possibly blocking until there's room available in the channel.
      boolean send​(Message 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.
      java.lang.String toString()  
      boolean trySend​(Message 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
    • Constructor Detail

      • ThreadSendPort

        public ThreadSendPort​(SendPort<Message> p)
        Creates a new convenience wrapper for using a SendPort in a thread.
        Parameters:
        p - the SendPort to wrap.
    • Method Detail

      • send

        public void send​(Message message)
                  throws java.lang.InterruptedException
        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.
        Parameters:
        message -
        Throws:
        java.lang.InterruptedException
      • send

        public boolean send​(Message message,
                            long timeout,
                            java.util.concurrent.TimeUnit unit)
                     throws java.lang.InterruptedException
        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.
        Parameters:
        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:
        java.lang.InterruptedException
      • trySend

        public boolean trySend​(Message message)
        Sends a message to the channel if the channel has room available. This method never blocks.
        Parameters:
        message -
        Returns:
        true if the message has been sent; false otherwise.
      • close

        public void close()
        Closes the channel so that no more messages could be sent to it.
      • hashCode

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

        public final boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

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