Class ZippingReceivePort<Message>
- java.lang.Object
-
- co.paralleluniverse.strands.channels.ZippingReceivePort<Message>
-
- All Implemented Interfaces:
Port<Message>
,PortAutoCloseable
,ReceivePort<Message>
,java.lang.AutoCloseable
public class ZippingReceivePort<Message> extends java.lang.Object implements ReceivePort<Message>
Single consumer
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface co.paralleluniverse.strands.channels.ReceivePort
ReceivePort.EOFException
-
-
Constructor Summary
Constructors Constructor Description ZippingReceivePort(ReceivePort<?>... targets)
ZippingReceivePort(com.google.common.base.Function<java.lang.Object[],Message> f, ReceivePort<?>... targets)
ZippingReceivePort(com.google.common.base.Function<java.lang.Object[],Message> f, java.util.List<? extends ReceivePort<?>> targets)
ZippingReceivePort(java.util.List<? extends ReceivePort<?>> targets)
-
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.Message
receive()
Retrieves a message from the channels, possibly blocking until one becomes available.Message
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.Message
receive(Timeout timeout)
Retrieves a message from the channels, possibly blocking until one becomes available, but no longer than the specified timeout.protected Message
transform(java.lang.Object[] ms)
Message
tryReceive()
Retrieves a message from the channel if one is available.
-
-
-
Constructor Detail
-
ZippingReceivePort
public ZippingReceivePort(com.google.common.base.Function<java.lang.Object[],Message> f, ReceivePort<?>... targets)
-
ZippingReceivePort
public ZippingReceivePort(com.google.common.base.Function<java.lang.Object[],Message> f, java.util.List<? extends ReceivePort<?>> targets)
-
ZippingReceivePort
public ZippingReceivePort(ReceivePort<?>... targets)
-
ZippingReceivePort
public ZippingReceivePort(java.util.List<? extends ReceivePort<?>> targets)
-
-
Method Detail
-
receive
public Message receive() throws SuspendExecution, java.lang.InterruptedException
Description copied from interface:ReceivePort
Retrieves a message from the channels, possibly blocking until one becomes available.- Specified by:
receive
in interfaceReceivePort<Message>
- Returns:
- a message, or
null
if the channel has been closed and no more messages await (seePortAutoCloseable.isClosed()
). - Throws:
SuspendExecution
java.lang.InterruptedException
-
tryReceive
public Message tryReceive()
Description copied from interface:ReceivePort
Retrieves a message from the channel if one is available. This method never blocks.- Specified by:
tryReceive
in interfaceReceivePort<Message>
- Returns:
- a message, or
null
if one is not immediately available.
-
receive
public Message 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 interfaceReceivePort<Message>
- 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 (seePortAutoCloseable.isClosed()
), or if the timeout has expired. - Throws:
SuspendExecution
java.lang.InterruptedException
-
receive
public Message 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 interfaceReceivePort<Message>
- Parameters:
timeout
- the method will not block for longer than the amount remaining in theTimeout
- Returns:
- a message, or
null
if the channel has been closed and no more messages await (seePortAutoCloseable.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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacePortAutoCloseable
-
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 returnstrue
all future calls toreceive
are guaranteed to returnnull
, and calls toreceive
on a primitive channel will throw aEOFException
.- Specified by:
isClosed
in interfacePortAutoCloseable
- Returns:
true
if the channels has been closed and no more messages will be received;false
otherwise.
-
transform
protected Message transform(java.lang.Object[] ms)
-
-