Package co.paralleluniverse.actors
Class Mailbox<Message>
- java.lang.Object
-
- co.paralleluniverse.strands.channels.QueueChannel<Message>
-
- co.paralleluniverse.strands.channels.SingleConsumerQueueChannel<Message>
-
- co.paralleluniverse.actors.Mailbox<Message>
-
- All Implemented Interfaces:
Channel<Message>,Port<Message>,PortAutoCloseable,ReceivePort<Message>,Selectable<Message>,SendPort<Message>,StandardChannel<Message>,Stranded,Synchronization,java.io.Serializable,java.lang.AutoCloseable
public final class Mailbox<Message> extends SingleConsumerQueueChannel<Message>
A channel that is used as an actor's mailbox. This class should only be used by actors- 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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidawait(int iter)voidawait(int iter, long timeout, java.util.concurrent.TimeUnit unit)voidclose()Closes the channel so that no more messages could be sent to it.booleanisClosed()This method must only be called by the channel's owner (the receiver)voidlock()voidmaybeSetCurrentStrandAsOwner()protected co.paralleluniverse.strands.queues.SingleConsumerQueue<Message>queue()protected voidsendSync(Message message)voidunlock()protected java.lang.ObjectwriteReplace()-
Methods inherited from class co.paralleluniverse.strands.channels.SingleConsumerQueueChannel
checkClosed, getOwner, getStrand, isOwnerAlive, receive, receive, setStrand, toString, tryReceive
-
Methods inherited from class co.paralleluniverse.strands.channels.QueueChannel
capacity, close, equals, getCloseException, getOverflowPolicy, getQueueLength, isSingleConsumer, isSingleProducer, receive, receiveFromThread, receiveFromThread, register, register, send, send, send, send0, sendNonSuspendable, signalAndWait, signalReceivers, sync, tryNow, trySend, unregister
-
-
-
-
Method Detail
-
close
public void close()
Description copied from interface:PortAutoCloseableCloses the channel so that no more messages could be sent to it. Messages already sent to the channel will still be received.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacePortAutoCloseable- Overrides:
closein classQueueChannel<Message>
-
isClosed
public boolean isClosed()
Description copied from class:QueueChannelThis method must only be called by the channel's owner (the receiver)- Specified by:
isClosedin interfacePortAutoCloseable- Overrides:
isClosedin classQueueChannel<Message>- Returns:
trueif the channels has been closed and no more messages will be received;falseotherwise.
-
queue
protected co.paralleluniverse.strands.queues.SingleConsumerQueue<Message> queue()
- Overrides:
queuein classSingleConsumerQueueChannel<Message>
-
sendSync
protected void sendSync(Message message) throws SuspendExecution
- Overrides:
sendSyncin classQueueChannel<Message>- Throws:
SuspendExecution
-
maybeSetCurrentStrandAsOwner
public void maybeSetCurrentStrandAsOwner()
- Overrides:
maybeSetCurrentStrandAsOwnerin classSingleConsumerQueueChannel<Message>
-
lock
public void lock()
-
unlock
public void unlock()
-
await
public void await(int iter) throws SuspendExecution, java.lang.InterruptedException- Throws:
SuspendExecutionjava.lang.InterruptedException
-
await
public void await(int iter, long timeout, java.util.concurrent.TimeUnit unit) throws SuspendExecution, java.lang.InterruptedException- Throws:
SuspendExecutionjava.lang.InterruptedException
-
writeReplace
protected java.lang.Object writeReplace() throws java.io.ObjectStreamException- Overrides:
writeReplacein classQueueChannel<Message>- Throws:
java.io.ObjectStreamException
-
-