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 void
await(int iter)
void
await(int iter, long timeout, java.util.concurrent.TimeUnit unit)
void
close()
Closes the channel so that no more messages could be sent to it.boolean
isClosed()
This method must only be called by the channel's owner (the receiver)void
lock()
void
maybeSetCurrentStrandAsOwner()
protected co.paralleluniverse.strands.queues.SingleConsumerQueue<Message>
queue()
protected void
sendSync(Message message)
void
unlock()
protected java.lang.Object
writeReplace()
-
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: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
- Overrides:
close
in classQueueChannel<Message>
-
isClosed
public boolean isClosed()
Description copied from class:QueueChannel
This method must only be called by the channel's owner (the receiver)- Specified by:
isClosed
in interfacePortAutoCloseable
- Overrides:
isClosed
in classQueueChannel<Message>
- Returns:
true
if the channels has been closed and no more messages will be received;false
otherwise.
-
queue
protected co.paralleluniverse.strands.queues.SingleConsumerQueue<Message> queue()
- Overrides:
queue
in classSingleConsumerQueueChannel<Message>
-
sendSync
protected void sendSync(Message message) throws SuspendExecution
- Overrides:
sendSync
in classQueueChannel<Message>
- Throws:
SuspendExecution
-
maybeSetCurrentStrandAsOwner
public void maybeSetCurrentStrandAsOwner()
- Overrides:
maybeSetCurrentStrandAsOwner
in classSingleConsumerQueueChannel<Message>
-
lock
public void lock()
-
unlock
public void unlock()
-
await
public void await(int iter) throws SuspendExecution, java.lang.InterruptedException
- Throws:
SuspendExecution
java.lang.InterruptedException
-
await
public void await(int iter, long timeout, java.util.concurrent.TimeUnit unit) throws SuspendExecution, java.lang.InterruptedException
- Throws:
SuspendExecution
java.lang.InterruptedException
-
writeReplace
protected java.lang.Object writeReplace() throws java.io.ObjectStreamException
- Overrides:
writeReplace
in classQueueChannel<Message>
- Throws:
java.io.ObjectStreamException
-
-