Class ReceivePortGroup<M>

    • Constructor Detail

      • ReceivePortGroup

        public ReceivePortGroup​(java.util.Collection<? extends ReceivePort<? extends M>> ports,
                                boolean alwaysOpen)
      • ReceivePortGroup

        public ReceivePortGroup​(java.util.Collection<? extends ReceivePort<? extends M>> ports)
      • ReceivePortGroup

        public ReceivePortGroup​(ReceivePort<? extends M>... ports)
      • ReceivePortGroup

        public ReceivePortGroup​(boolean alwaysOpen)
      • ReceivePortGroup

        public ReceivePortGroup()
    • Method Detail

      • tryReceive

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

        public M 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<M>
        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
      • receive

        public M receive​(long timeout,
                         java.util.concurrent.TimeUnit unit)
                  throws java.lang.InterruptedException,
                         SuspendExecution
        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<M>
        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:
        java.lang.InterruptedException
        SuspendExecution
      • 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.
      • remove

        public <T extends ReceivePort<? extends M>> void remove​(T... items)
                                                         throws SuspendExecution,
                                                                java.lang.InterruptedException
        Specified by:
        remove in interface Mix<M>
        Parameters:
        items - If null or empty, all items will be removed.
        Throws:
        SuspendExecution
        java.lang.InterruptedException
      • getState

        public <T extends ReceivePort<? extends M>> java.util.Map<T,​Mix.State> getState​(T... items)
        Specified by:
        getState in interface Mix<M>
        Parameters:
        items - If null or empty, all items will be removed.
      • setState

        public <T extends ReceivePort<? extends M>> void setState​(Mix.State state,
                                                                  T... items)
                                                           throws SuspendExecution,
                                                                  java.lang.InterruptedException
        Specified by:
        setState in interface Mix<M>
        items - If null or empty, all items state will be set to state.
        Throws:
        SuspendExecution
        java.lang.InterruptedException