Class QueueDoubleChannel
- java.lang.Object
-
- co.paralleluniverse.strands.channels.QueueChannel<Message>
-
- co.paralleluniverse.strands.channels.QueuePrimitiveChannel<java.lang.Double>
-
- co.paralleluniverse.strands.channels.QueueDoubleChannel
-
- All Implemented Interfaces:
Channel<java.lang.Double>
,DoubleChannel
,DoubleReceivePort
,DoubleSendPort
,Port<java.lang.Double>
,PortAutoCloseable
,ReceivePort<java.lang.Double>
,Selectable<java.lang.Double>
,SendPort<java.lang.Double>
,StandardChannel<java.lang.Double>
,Stranded
,Synchronization
,java.io.Serializable
,java.lang.AutoCloseable
public class QueueDoubleChannel extends QueuePrimitiveChannel<java.lang.Double> implements DoubleChannel
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface co.paralleluniverse.strands.channels.ReceivePort
ReceivePort.EOFException
-
-
Field Summary
-
Fields inherited from class co.paralleluniverse.strands.channels.QueueChannel
RECORDER
-
-
Constructor Summary
Constructors Constructor Description QueueDoubleChannel(co.paralleluniverse.strands.queues.BasicSingleConsumerDoubleQueue queue, Channels.OverflowPolicy policy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected co.paralleluniverse.strands.queues.BasicSingleConsumerDoubleQueue
queue()
double
receiveDouble()
Retrieves a message from the channels, possibly blocking until one becomes available.double
receiveDouble(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.double
receiveDouble(Timeout timeout)
Retrieves a message from the channels, possibly blocking until one becomes available, but no longer than the specified timeout.void
send(double message)
Sends a message to the channel, possibly blocking until there's room available in the channel.boolean
send(double 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(double 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.boolean
trySend(double message)
Sends a message to the channel if the channel has room available.-
Methods inherited from class co.paralleluniverse.strands.channels.QueuePrimitiveChannel
checkClosed, getStrand, hasMessage, maybeSetCurrentStrandAsOwner, setStrand
-
Methods inherited from class co.paralleluniverse.strands.channels.QueueChannel
capacity, close, close, equals, getCloseException, getOverflowPolicy, getQueueLength, isClosed, isSingleConsumer, isSingleProducer, receive, receive, receive, receiveFromThread, receiveFromThread, register, register, send, send, send, send0, sendNonSuspendable, sendSync, signalAndWait, signalReceivers, sync, toString, tryNow, tryReceive, trySend, unregister, writeReplace
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface co.paralleluniverse.strands.channels.DoubleReceivePort
hasMessage
-
Methods inherited from interface co.paralleluniverse.strands.channels.PortAutoCloseable
close, isClosed
-
Methods inherited from interface co.paralleluniverse.strands.channels.ReceivePort
receive, receive, receive, tryReceive
-
-
-
-
Constructor Detail
-
QueueDoubleChannel
public QueueDoubleChannel(co.paralleluniverse.strands.queues.BasicSingleConsumerDoubleQueue queue, Channels.OverflowPolicy policy)
-
-
Method Detail
-
receiveDouble
public double receiveDouble() throws SuspendExecution, java.lang.InterruptedException, ReceivePort.EOFException
Description copied from interface:DoubleReceivePort
Retrieves a message from the channels, possibly blocking until one becomes available. If the channel has been closed and no more messages await, this method throws anReceivePort.EOFException
.- Specified by:
receiveDouble
in interfaceDoubleReceivePort
- Returns:
- a message.
- Throws:
java.lang.InterruptedException
ReceivePort.EOFException
- if the channel has been closed and no more messages awaitSuspendExecution
-
receiveDouble
public double receiveDouble(long timeout, java.util.concurrent.TimeUnit unit) throws SuspendExecution, java.lang.InterruptedException, java.util.concurrent.TimeoutException, ReceivePort.EOFException
Description copied from interface:DoubleReceivePort
Retrieves a message from the channels, possibly blocking until one becomes available, but no longer than the specified timeout. If the channel has been closed and no more messages await, this method throws anReceivePort.EOFException
.- Specified by:
receiveDouble
in interfaceDoubleReceivePort
- Parameters:
timeout
- the maximum duration to block waiting for a message.unit
- the time unit of the timeout.- Returns:
- a message. (see
PortAutoCloseable.isClosed()
), or if the timeout has expired. - Throws:
java.lang.InterruptedException
java.util.concurrent.TimeoutException
- if the timeout has expiredReceivePort.EOFException
- if the channel has been closed and no more messages awaitSuspendExecution
-
receiveDouble
public double receiveDouble(Timeout timeout) throws SuspendExecution, java.lang.InterruptedException, java.util.concurrent.TimeoutException, ReceivePort.EOFException
Description copied from interface:DoubleReceivePort
Retrieves a message from the channels, possibly blocking until one becomes available, but no longer than the specified timeout. If the channel has been closed and no more messages await, this method throws anReceivePort.EOFException
.- Specified by:
receiveDouble
in interfaceDoubleReceivePort
- Parameters:
timeout
- the method will not block for longer than the amount remaining in theTimeout
- Returns:
- a message. (see
PortAutoCloseable.isClosed()
), or if the timeout has expired. - Throws:
java.lang.InterruptedException
java.util.concurrent.TimeoutException
- if the timeout has expiredReceivePort.EOFException
- if the channel has been closed and no more messages awaitSuspendExecution
-
trySend
public boolean trySend(double message)
Description copied from interface:DoubleSendPort
Sends a message to the channel if the channel has room available. This method never blocks.- Specified by:
trySend
in interfaceDoubleSendPort
- Returns:
true
if the message has been sent;false
otherwise.
-
send
public void send(double message) throws SuspendExecution, java.lang.InterruptedException
Description copied from interface:DoubleSendPort
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'sOverflowPolicy
, set at construction time.- Specified by:
send
in interfaceDoubleSendPort
- Throws:
SuspendExecution
java.lang.InterruptedException
-
send
public boolean send(double message, long timeout, java.util.concurrent.TimeUnit unit) throws SuspendExecution, java.lang.InterruptedException
Description copied from interface:DoubleSendPort
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'sOverflowPolicy
, set at construction time.- Specified by:
send
in interfaceDoubleSendPort
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(double message, Timeout timeout) throws SuspendExecution, java.lang.InterruptedException
Description copied from interface:DoubleSendPort
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'sOverflowPolicy
, set at construction time.- Specified by:
send
in interfaceDoubleSendPort
timeout
- the method will not block for longer than the amount remaining in theTimeout
- Returns:
true
if the message has been sent successfully;false
if the timeout has expired.- Throws:
SuspendExecution
java.lang.InterruptedException
-
queue
protected co.paralleluniverse.strands.queues.BasicSingleConsumerDoubleQueue queue()
- Overrides:
queue
in classQueuePrimitiveChannel<java.lang.Double>
-
-