java.io.Serializable
, java.rmi.Remote
, Mailbox<Msg>
SinkBox
public class QueuedMailbox<Msg extends java.io.Serializable>
extends java.rmi.server.UnicastRemoteObject
Modifier and Type | Field | Description |
---|---|---|
protected int |
capacity |
|
protected int |
depositBlocks |
|
protected boolean |
open |
|
protected java.util.LinkedList<Msg> |
queue |
Modifier | Constructor | Description |
---|---|---|
protected |
QueuedMailbox(java.lang.Class<Msg> msgClass,
int capacity) |
A new QueuedMailbox with given CAPACITY carrying messages of type
MSGCLASS.
|
Modifier and Type | Method | Description |
---|---|---|
int |
capacity() |
The capacity (see interface comment above) of THIS.
|
<T extends java.io.Serializable> |
checkType(java.lang.Class<T> msgClass) |
Returns THIS, assuming that THIS conveys messages of class MSGCLASS.
|
void |
close() |
Short for close (0).
|
void |
close(long millis) |
Performs a flush(MILLIS) and then invalidates THIS for all future
use, deleting all remaining messages.
|
static <Msg extends java.io.Serializable> |
create(int capacity) |
A new QueuedMailbox with capacity () fixed at CAPACITY, with
no type checking.
|
static <Msg extends java.io.Serializable> |
create(java.lang.Class<Msg> msgClass,
int capacity) |
A new QueuedMailbox
|
void |
deposit(Msg msg) |
Deposit MSG in this Mailbox.
|
boolean |
deposit(Msg msg,
long millis) |
Deposit MSG in this Mailbox, if this can be done within approximately
MILLIS milliseconds.
|
protected void |
enqueue(Msg msg) |
Place MSG at the end of the message queue.
|
boolean |
flush(long millis) |
Wait for all queued messages to be received, or MILLIS milliseconds,
whichever comes first.
|
protected void |
forward(Msg msg,
long millis) |
Perform forwarding of MSG to all recipients, waiting for up to
MILLIS milliseconds for each deposit to be accepted.
|
void |
forwardTo(java.util.List<Mailbox<Msg>> boxes) |
Forward copies of all messages (including any already present) to BOXES
in the order received.
|
void |
forwardTo(Mailbox<Msg> box) |
Forward copies of all messages (including any already present) to BOXES
in the order received.
|
boolean |
isClosed() |
True iff THIS is closed.
|
boolean |
isForwarding() |
True iff THIS is currently forwarding messages as a result of
forwardTo.
|
java.lang.Class<Msg> |
messageType() |
The (runtime) type of message sent through this box.
|
protected long |
myWait(long limit) |
Wait for up to LIMIT milliseconds or the next notify or interrupt.
|
Msg |
receive() |
Receive the next queued message in this Mailbox.
|
Msg |
receive(long millis) |
Receive the next queued message in this Mailbox, if one is
available within MILLIS milliseconds.
|
void |
stopForwarding() |
Stop forwarding copies of messages.
|
finalize, getClass, notify, notifyAll, wait, wait, wait
protected final java.util.LinkedList<Msg extends java.io.Serializable> queue
protected int capacity
protected boolean open
protected int depositBlocks
protected QueuedMailbox(java.lang.Class<Msg> msgClass, int capacity) throws java.rmi.RemoteException
java.rmi.RemoteException
public static <Msg extends java.io.Serializable> QueuedMailbox<Msg> create(java.lang.Class<Msg> msgClass, int capacity)
public static <Msg extends java.io.Serializable> QueuedMailbox<Msg> create(int capacity)
public void deposit(Msg msg) throws java.lang.InterruptedException, java.rmi.RemoteException
java.lang.InterruptedException
java.rmi.RemoteException
public boolean deposit(Msg msg, long millis) throws java.lang.InterruptedException, java.rmi.RemoteException
java.lang.InterruptedException
java.rmi.RemoteException
public Msg receive() throws java.lang.InterruptedException
java.lang.InterruptedException
public Msg receive(long millis) throws java.lang.InterruptedException
java.lang.InterruptedException
public void forwardTo(Mailbox<Msg> box) throws java.lang.InterruptedException, java.rmi.RemoteException
java.lang.InterruptedException
java.rmi.RemoteException
public void forwardTo(java.util.List<Mailbox<Msg>> boxes) throws java.lang.InterruptedException, java.rmi.RemoteException
java.lang.InterruptedException
java.rmi.RemoteException
public void stopForwarding()
public boolean flush(long millis) throws java.lang.InterruptedException
java.lang.InterruptedException
public void close(long millis) throws java.lang.InterruptedException
java.lang.InterruptedException
public void close() throws java.lang.InterruptedException
java.lang.InterruptedException
public boolean isForwarding()
public boolean isClosed()
public int capacity()
protected void enqueue(Msg msg)
protected void forward(Msg msg, long millis) throws java.rmi.RemoteException, java.lang.InterruptedException
java.rmi.RemoteException
java.lang.InterruptedException
protected long myWait(long limit) throws java.lang.InterruptedException
java.lang.InterruptedException
public java.lang.Class<Msg> messageType()
Mailbox
messageType
in interface Mailbox<Msg extends java.io.Serializable>