Class ValChannel<V>

    • Constructor Summary

      Constructors 
      Constructor Description
      ValChannel​(Val<V> val)  
    • 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 isClosed()
      Tests whether the channel has been closed and no more messages await in the channel.
      V receive()
      Retrieves a message from the channels, possibly blocking until one becomes available.
      V 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.
      V receive​(Timeout timeout)
      Retrieves a message from the channels, possibly blocking until one becomes available, but no longer than the specified timeout.
      java.lang.Object register​(SelectAction<V> action1)  
      boolean tryNow​(java.lang.Object token)  
      V tryReceive()
      Retrieves a message from the channel if one is available.
      void unregister​(java.lang.Object token)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ValChannel

        public ValChannel​(Val<V> val)
    • Method Detail

      • tryReceive

        public V 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<V>
        Returns:
        a message, or null if one is not immediately available.
      • receive

        public V 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<V>
        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 V 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<V>
        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
      • 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.
      • tryNow

        public boolean tryNow​(java.lang.Object token)
        Specified by:
        tryNow in interface Selectable<V>
      • unregister

        public void unregister​(java.lang.Object token)
        Specified by:
        unregister in interface Selectable<V>